Use this API to send stateful information into Heap as a set of global key-value pairs that get attached to all of a user's subsequent events.

As a best practice, we recommend calling clearEventProperties before addEventProperties on every page. This removes all previous event properties from the cookie, which ensures the properties getting added by the next addEventProperties call are always relevant.

When you set a property value via this API, we’ll store this information in a cookie on the client-side and attach this property value to every event going forward until it’s updated or cleared. For this reason, this API is only available on the client-side.

Note that this API may not work well with Single Page Applications, which tend to change state in a way that impacts the timing of the cookie being sent to the API.

These event properties are stored in a cookie and will persist across multiple events and sessions on the same device. They're applied to both autocaptured and custom events. Note that there is a 4k limit on the sum of cookies per domain, and that properties may be dropped if the limit is exceeded.

This is useful if you have some persistent state, and you don't want it to apply to all of a user's events by calling addUserProperties. A good example is "Logged In", which changes over the user's lifecycle. You can use addEventProperties to measure how a user's behavior changes when they're logged in versus when they're logged out.

heap.addEventProperties({ 'Logged In': 'true', 'Payment Plan': 'Free' });
heap.addEventProperties({ 'Logged In': 'true', 'Payment Plan': 'Free' });
[Heap addEventProperties:@{@"Logged In": @"true", @"Payment Plan": @"Free"}];
Heap.addEventProperties(["Logged In": "true", "Payment Plan": "Free"])
Map<String, String> props = new HashMap<>();
props.put("Logged In", "true");
props.put("Payment Plan", "Free");
Heap.addEventProperties(props);
Heap.addEventProperties(mutableMapOf(
    "Logged In" to "true",
    "Payment Plan" to "Free"
))
Arguments
  1. event properties: a JSON object, NSDictionary, or Map containing key-value pairs to be associated with every subsequent event. Keys and values must be a number or string fewer than 1024 characters. All properties (keys and values) must be less than 4096 character in total, or they'll be dropped silently.

For Android, the property map keys and values must be converted to strings, but they can be analyzed as numbers in Heap.

Did you find what you were looking for?
Thumb up Thumb down