Properties

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:

let properties = Properties()

Set property

You can add properties using the putString() method. Every property is defined by a name and value.

properties["sample_property"] = "sample_value"

properties
   .setProperty("sample_property_1", to: "sample_value_1")
   .setProperty("sample_property_2", to: "sample_value_2")

🚧

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.

let sampleProperty = properties["sample_property"]

Remove property

You can remove any property using remove(), or by setting it to null.

properties["sample_name"] = nil
properties.setProperty("sample_property", to: nil)

Clear properties

You can clear all properties using keys:

for key in properties.keys {
	properties[key] = nil
}