Analytics

Custom event

Pre API 2.0

// Without properties
Smartlook.trackCustomEvent('sample_event');

// With properties
Smartlook.trackCustomEvent('sample_event', {'sample_key':'sample_value'});

API 2.0

JSONObject, Bundle, etc. are no longer supported and Properties are used.

//without properties
Smartlook.instance.trackEvent('event');

//with properties
final Properties properties = Properties();
properties.putString('sample_key', value: 'sample_value');
Smartlook.instance.trackEvent('event', properties: properties)

🚧

Event name restrictions

  • Cannot be empty or null.
  • The maximum length is 200 characters.
  • Contains only alphanumeric characters and “_”, " ", “.”, “-”.
  • Must start with an alphabetic character.

An event with an incorrect name will be dropped.

Track event documentation.
Properties documentation.

Navigation event

Pre API 2.0

Smartlook.trackNavigationEvent('nav-event', SmartlookNavigationEventType.enter);
Smartlook.trackNavigationEvent('nav-event', SmartlookNavigationEventType.exit);

API 2.0

ViewState and ViewType are no longer part of the API:

  • ViewState is not needed because there 2 methods enter and exit.
  • ViewType navigation events do not have any types and it's universal for all cases (Activity, Fragment, "custom").
Smartlook.instance.trackNavigationEnter('mock_screen');
Smartlook.instance.trackNavigationExit('mock_screen');

🚧

Navigation event name restrictions

  • Cannot be empty or null.
  • The maximum length is 200 characters.
  • Contains only alphanumeric characters and “_”, " ", “.”, “-”.
  • Must start with an alphabetic character.

An event with an incorrect name will be dropped.

Track navigation event documentation.

Global event properties

Pre API 2.0

//set one property that is immutable
Smartlook.setGlobalEventProperty("key_", "value_", true);
//set multtiple properties that are mutable
Smartlook.setGlobalEventProperties({"A": "B"}, false);
//remove property
Smartlook.removeGlobalEventProperty("A");
//remove all properties
Smartlook.removeAllGlobalEventProperties();

API 2.0

//set property
Smartlook.instance.eventProperties.putString('key', 'value');
//newly get propertySmartl
Smartlook.instance.eventProperties.getString("test");
//remove property
Smartlook.instance.eventProperties.removeString("test");
//remove all properties
Smartlook.instance.eventProperties.clear();

🚧

Properties mutability

All event properties are now mutable. If immutability of certain properties is needed it must be ensured on the client-side.

Event properties documentation.
Properties documentation.