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 custom events

You can track a custom event:

Smartlook.instance.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 incorrect name will be dropped.

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

final Properties properties = Properties();
properties.putString('sampleKey', value: 'sampleValue');
Smartlook.instance.trackEvent('sample_event',properties: properties);

📘

Properties API

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

Navigation events

Smartlook supports Navigator 1.0, Navigator 2.0, and GetX for navigation events.

Navigation events are not automatically tracked. However, you can set up automatic tracking of navigation events for Navigator 1.0 using MaterialPageRoute:

MaterialApp(
  navigatorObservers: [SmartlookObserver()],
)

To manually track screen and navigation transitions:

Smartlook.instance.trackNavigationEnter('SampleScreen');
Smartlook.instance.trackNavigationExit('SampleScreen');

🚧

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 incorrect name will be dropped.

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

final Properties enterProperties = Properties();
enterProperties.putString('sample_name', value: 'sample_value');
Smartlook.instance.trackNavigationEnter('SampleScreen', enterProperties);
  
final Properties exitProperties = Properties();
exitProperties.putString('sample_name', value: 'sample_value');
Smartlook.instance.trackNavigationEnter('SampleScreen', exitProperties);

📘

Properties API

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

Event properties

You can merge additional properties in every event properties:

Smartlook.instance.eventProperties.putString('sample_name', 'sample_value');

🚧

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 value stored in eventProperties 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 the Preferences and State documentation.