Manually track events
Tracking custom events
Section titled Tracking custom eventsIn addition to autocaptured events, Product Analytics also supports manual tracking of custom events using CSQ.trackEvent()
API.
CSQ.trackEvent("custom_event_name")
[CSQ trackEvent:@"custom_event_name"];
Adding properties to custom events
Section titled Adding properties to custom eventsCustom events can be enhanced with a set of properties that will correspond to the tracked event when passed into the CSQ.trackEvent()
API call.
CSQ.trackEvent("custom_event_with_properties", properties: [ "property1": "sample value", "property2": 10, "property3": false,])
[CSQ trackEvent:@"custom_event_with_properties" properties:@{ @"property1": @"sample value", @"property2": @10, @"property3": @NO}];
Adding properties to all events
Section titled Adding properties to all eventsIn some cases, you might want to add a property, or a collection of properties, to all events tracked by Product Analytics. Adding a global event property can be accomplished using CSQ.addEventProperties()
.
CSQ.addEventProperties([ "property1": "sample value", "property2": 10, "property3": false,])
[CSQ addEventProperties:@{ @"property1": @"sample value", @"property2": @10, @"property3": @NO}];
Properties that are added using the CSQ.addEventProperties()
API will be attached to all events tracked by Product Analytics, including any events that are automatically tracked by a CSQ autocapture SDK.
Once a property is no longer needed in the global collection, use this API to remove properties one at a time.
On the other hand, if you want to remove all properties added with CSQ.addEventProperties()
at once, you can achieve this by using CSQ.clearEventProperties()
.
CSQ.clearEventProperties()
[CSQ clearEventProperties];
However, neither of these methods will affect events that have already been processed.