You can create properties
objects to add additional information to events. You can then use this extra information to further break down the event.
Create Properties
Smartlook APIs provide user and event Properties
singletons. To create other Properties
for track events, use the default constructor:
val properties = Properties()
Properties properties = new Properties();
Put property
You can add properties using the putString()
method. Every property is defined by a name
and value
.
properties.putString("sample_name", "sample_value")
properties.putString("sample_key", "sample_value");
Name restrictions
- Cannot be empty or null.
- Maximum length is 200 characters.
- Can only contain alphanumeric characters, underscore (_), comma (,), period (.), and hyphen (-).
- Must start with an alphabetic character.
Value restrictions
- The maximum length is 5 kilobytes.
Get property
You can read any property using getString()
. If a property with the name
exists, the the value
is returned. Otherwise, null
is returned.
val sampleValue = properties.getString("sample_key")
String sampleValue = properties.getString("sample_key");
Remove property
You can remove any property using remove()
, or by setting it to null
.
properties.remove("sample_name")
properties.putString("sample_name", null)
properties.remove("sample_key");
properties.putString("sample_key", null);
Clear properties
You can clear all properties using clear()
:
properties.clear()
properties.clear();