Custom event
A simple custom event can be created by calling:
SmartlookUnity.Smartlook.TrackCustomEvent(string eventName);
Custom event also accepts a dictionary of string key/values as event properties.
// JSON string, obtained for example with JsonUtility.ToJson(param)
SmartlookUnity.TrackCustomEvent(string eventName, string properties);
Navigation event
Screen/navigation transitions can be manually tracked by calling:
SmartlookUnity.TrackNavigationEvent(string screenName, NavigationEventType direction);
Navigation events need to be tracked manually, because Unity applications typically consist of single activity. Manual tracking needs to be implemented so mobile heatmaps work correctly.
Timed event
Duration of any time-sensitive or long-running actions in the application can be measured using timed events. A timed event can be started by using the following:
SmartlookUnity.Smartlook.StartTimedCustomEvent(string eventName);
SmartlookUnity.Smartlook.StartTimedCustomEvent(string eventName, string properties)
This will not send out any events but will return a unique eventId
that needs to be stored and it is then used to stop/cancel a custom timed event. To send out an event with a duration, stop needs to be called:
SmartlookUnity.Smartlook.StopTimedCustomEvent(string eventId);
SmartlookUnity.Smartlook.StopTimedCustomEvent(string eventId, string properties);
with corresponding eventId
obtained from StartTimedCustomEvent
.
Properties set in start will be merged with properties set in stop/cancel. Properties from stop/cancel have a higher priority and will rewrite conflicting properties from the start.
In case a given action failed CancelTimedCustomEvent()
can be called instead of StopTimedCustomEvent()
it has an extra field used for the reason of any failure:
SmartlookUnity.Smartlook.CancelTimedCustomEvent(string eventId, string reason);
SmartlookUnity.Smartlook.CancelTimedCustomEvent(string eventId, string reason, string properties);
Global event properties
Extra properties can be attached to every event, these properties are called global event properties. Global event properties can be set by calling:
SmartlookUnity.Smartlook.SetGlobalEventProperty(string key, string value, bool immutable);
SmartlookUnity.Smartlook.SetGlobalEventProperties(string properties, bool immutable);
Properties set to be immutable have the highest priority and once set they cannot be overridden (only removed).
Global event properties have higher a priority so in the merging process they will override custom properties with the same key.
Remove global event properties
A global property with a given key can be removed:
SmartlookUnity.Smartlook.RemoveGlobalEventProperty(string key);
Or all global event properties can be removed at once:
SmartlookUnity.Smartlook.RemoveAllGlobalEventProperties();
Global event properties are stored until they are not removed or the app is uninstalled.
Event tracking modes
It can be beneficial to disable some automatically detected events due to security or usability reasons. This can be done using event tracking modes:
FULL_TRACKING
: this a default state. SDK tracks all automatically detected events along with all user defined events.IGNORE_USER_INTERACTION
: disables automatically detected selector (click on aView
), focus, touch, gesture and keyboard events.IGNORE_NAVIGATION_INTERACTION
: disables automatically detected navigation events. User defined ones are still being sent.IGNORE_RAGE_CLICKS
: disables automatic detection and tracking of rage click events.NO_TRACKING
: no automatically detected events are tracked. Only user defined events are still tracked.
Set event tracking modes
Single or a combination of event tracking modes can be set any time after SDK setup by using the following:
SmartlookUnity.Smartlook.setEventTrackingMode(EventTrackingMode eventTrackingMode);
SmartlookUnity.Smartlook.setEventTrackingModes(List<EventTrackingMode> eventTrackingModes);
Next reading
- Further info about event tracking modes could be found in the Event Tracking conceptual document.
- Also take a look at the pin code keyboard sample, demonstrating usage of analytic event modes.