Analytics

Smartlook automatically tracks a number of events in user sessions. To read more what is automatically tracked, see Event Tracking. You can also create custom events to track events that are not automatically tracked.

🚧

Events can be tracked only when the SDK is running.

Tracking a custom event

You can track a custom event :

Smartlook.instance.analytics.trackEvent("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 a properties object:

import Smartlook, { Properties } from 'react-native-smartlook-analytics';

const properties = new Properties();
properties.putString("sample-key", "event");

Smartlook.instance.analytics.trackEvent("sample-event", properties);

📘

Properties API

Full documentation on using put, get, and remove properties can be found in the properties section.

Navigation event

To manually track screen and navigation transitions:

Smartlook.instance.analytics.trackNavigationEnter("SampleScreen");
Smartlook.instance.analytics.trackNavigationExit("SampleScreen");

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

🚧

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 properties in every event properties:

Smartlook.instance.analytics.putStringEventProperty("sample-name", "sample-value");

const eventPropertyValue = await Smartlook.instance.analytics.getStringEventProperty("sample-name");

Smartlook.instance.analytics.removeEventProperty("sample-name");

🚧

Override priority

Properties set in eventProperties 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.

📘

Properties API

You can read full documentation on using put, get, and remove properties in the properties section.

Automatic event tracking

You can enable or disable automatically tracked event using the Tracking API. For more information on the Tracking API, see Preferences & State documentation.