Analytics

On web-based frameworks (such as Cordova), the SDK is not able to autodetect all events as on native frameworks (see Event tracking). For most of the user interaction a custom events need to be used.

🚧

Events can be tracked only when the SDK is running.

Tracking custom events

You can track a custom event :

Smartlook.trackEvent({ eventName: "sample-event" });

🚧

Event name restrictions

  • Cannot be empty or null
  • Maximum length is 200 characters
  • Contains only alphanumeric characters, underscore (_), comma (,), period (.), and hyphen (-)
  • Must start with an alphabetic character

An event with an invalid name will be dropped.

You can add additional data to the event as an optional props object:


const props = {
  "sample-key": "sample-value"
};

Smartlook.trackEvent({ eventName: "sample-event", props });

🚧

Properties structure restrictions

Event properties use only flat objects. If you use an object that includes objects or arrays as a child element, these elements will be ignored.

Navigation event

To manually track screen and navigation transitions:

Smartlook.trackNavigationEnter({ eventName: "SampleScreen", props? });
Smartlook.trackNavigationExit({ eventName: "SampleScreen", props? });

You can add additional data to the navigation event as a props object.

❗️

Manual navigation event tracking

Navigation events need to be tracked manually because web technology-based applications typically consist of a single activity. Manual tracking needs to be implemented so mobile heatmaps work correctly.

🚧

Navigation event name restrictions

  • Cannot be empty or null
  • Maximum length is 200 characters
  • Contains only alphanumeric characters, underscore (_), comma (,), period (.), and hyphen (-)
  • Must start with an alphabetic character

A navigation event with an invalid name will be dropped.

Event properties

You can merge additional global properties in every event props:

Smartlook.putGlobalEventProperty({ propertyName: "sample-name", propertyValue: "sample-value" });

Smartlook.removeEventProperty({ propertyName: "sample-name" });

const globalEventProperty = await Smartlook.getGlobalEventProperty({ propertyName: "sample-name" });

🚧

Override priority

Properties set in props have a lower priority than properties defined in one of the track() calls. This means that if there are properties with the same name in both, the local property value from the track() call will be kept.