Smartech

Configuring Analytics via CleverTap

Step 1: Create new Class

Create a new class "AppCleverTap" and add the following method to it.

#import <SmartechNudges/Hansel-umbrella.h>

+ (void) recordEvent: (NSString*) eventName withProperties: (id) properties{
    //Check if this event is being tracked in any one of the active Hansel Interaction Maps.
    //Please pass the string "ctp" for vendor if you are using Clevertap to track the event.
  //get the data for all Interaction Maps created on hansel dashboard.
    NSDictionary* hanselData = [HanselTracker logEvent:eventName andVendor:@"ctp" withProperties:properties];
    if (![properties isKindOfClass:[NSMutableDictionary class]]){
        properties = [properties mutableCopy];
    }
    [properties addEntriesFromDictionary:hanselData];
    [[CleverTap sharedInstance] recordEvent:eventName withProps:properties];
}
static func recordEvent(_ eventName: String, properties: [AnyHashable: Any]) {
        var properties = properties
        //Check if this event is being tracked in any one of the active Hansel Interaction Maps
        //Please pass the string "ctp" for vendor if you are using Clevertap to track the event.
        //get the data for all Interaction Maps created on hansel dashboard.
        let hanselData = HanselTracker.logEvent(eventName, vendor: "ctp", withProperties: properties)
        for (k, v) in hanselData { properties[k] = v }        
        CleverTap.sharedInstance()?.recordEvent(eventName, withProps: properties)
}

Step 2: Update code

For all those events on which you want to track the impact of Hansel changes, make the updates as suggested in the snippet below:

#import <SmartechNudges/Hansel-umbrella.h>

//If the original code was
[[CleverTap sharedInstance] recordEvent:eventName withProps:properties];

//it would get updated to
[AppCleverTap recordEvent:eventName withProperties:properties];
//If the original code was
CleverTap.sharedInstance()?.recordEvent(eventName, withProps: properties)

//it would get updated to
AppCleverTap.recordEvent(eventName, properties: properties)

Updated 6 months ago


Next

Continue setting up Product experience

Product Experience

Configuring Analytics via CleverTap


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.