Smartech

Configuring Analytics via Segment

Step 1: Create new Class

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

#import <SmartechNudges/Hansel-umbrella.h>

+ (void) track: (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 "smt" for vendor if you are using Segment to track the event.
  //get the data for all Interaction Maps created on hansel dashboard.
   NSDictionary* hanselData = [HanselTracker logEvent:eventName andVendor:@"sgmt" withProperties:properties];
    if (![properties isKindOfClass:[NSMutableDictionary class]]){
        properties = [properties mutableCopy];
    }
    [properties addEntriesFromDictionary:hanselData];
    [[SEGAnalytics sharedAnalytics] track:eventName properties:properties];
}
static func track(_ 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 "smt" for vendor if you are using Segment to track the event.
       //getting the data for all interaction maps on hansel dashboard
              let hanselData = HanselTracker.logEvent(eventName, vendor: "sgmt", withProperties: properties)
            for (k, v) in hanselData { properties[k] = v }  
        SEGAnalytics.shared().track(eventName, properties: properties as? [String : Any])
    }

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
[[SEGAnalytics sharedAnalytics] track:eventName properties:properties];

//it would get updated to
[AppSegment track:eventName properties:properties];
//If the original code was
SEGAnalytics.shared().track(eventName, properties:properties)

//it would get updated to
AppSegment.track(eventName, properties: properties)

Updated 2 days ago


Next

Continue setting up Product experience

Product Experience

Configuring Analytics via Segment


Suggested Edits are limited on API Reference Pages

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