Smartech

Configuring Analytics via Localytics

Step 1: Create new Class

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

#import <SmartechNudges/Hansel-umbrella.h>

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

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
[Localytics tagEvent:eventName attributes:attributes];

//it would get updated to
[AppLocalytics tagEvent:eventName attributes:attributes];
//If the original code was
Localytics.tagEvent(eventName, attributes: attributes)

//it would get updated to
AppLocalytics.tagEvent(eventName, attributes: attributes)

Updated 6 months ago


Next

Continue setting up Product experience

Product Experience

Configuring Analytics via Localytics


Suggested Edits are limited on API Reference Pages

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