Custom Properties

Bring your own data to the party!

You can add your own custom properties for use in the conditional targeting system. Adding more data about your users/app can provide more powerful options for targeting and optimization.

Well Known vs Custom Properties

There are two types of custom properties:

  • Well known properties: A set of properties we define, and you set. These are common things that most apps have like "user_signup_date". By using this well known set, our optimization system can incorporate these properties (when provided) and make smarter optimization decisions. We suggest you set as many of these that make sense for your app's user experience.

  • Custom properties can be any key/value pairs which you might find useful for targeting

Well Known Property List

Setting Properties in Code

You can set properties in code using the following functions of the CriticalMoments.sharedInstance object.

Properties must be set before calling start on CriticalMoments. Properties set after calling start will be ignored.

let cm = CriticalMoments.sharedInstance()
cm.registerBoolProperty(true, forKey: "has_pro_account", error: nil)
cm.registerIntegerProperty(42, forKey: "max_game_level", error: nil)
cm.registerStringProperty("creator", forKey: "user_persona", error: nil)
cm.registerFloatProperty(42.42, forKey: "total_spending", error: nil)
cm.registerTimeProperty(, forKey: "account_upgrade_timestamp", error: nil)

Setting Many Properties via JSON

You can set a set of properties from JSON formatted data. This can be very helpful, allowing your to add properties to shipping clients without updating the app.

Properties must be set before calling [CriticalMoments.sharedInstance start]. Properties set after calling start will be ignored.

Generally this API is used like follows:

  • You create a server endpoint (for example /user_properties), which is authenticated and retrieves information about this user in JSON format.

  • Call this server API on launch, and then pass the resulting JSON to registerPropertiesFromJson

  • Optionally cache this result for faster startup (used cache results on launch, refresh cache for next launch).

let jsonData = """
  "bool_property": true,
  "int_property": 42,
  "float_property": 42.42,
  "string_property": "hello world"
""".data(using: .utf8)!

var jsonError : NSError?
CriticalMoments.sharedInstance().registerProperties(fromJson: jsonData, error: &jsonError)
if jsonError != nil {
    NSLog("There was an issue parsing the json: %@", jsonError!.localizedDescription)

Last updated