These docs are for v1.0. Click to read the latest docs for v2.0.

Nudges - Configuring Analytics

❗️

Page load events in Anchored nudges

Hansel requires page load events to be fired only post rendering the Activity. This is to ensure that the anchored nudges are placed agains the right element in the View. Please refer here for more information about setting up page load events in your app.

Note - If used incorrectly, anchored nudges may be skipped when the activity has not been rendered

Sending Hansel data to Analytics Vendor

Follow this section if you wish to use events from any of these analytics providers as goal event and send Hansel data back to these vendors.

Using Smartech

If you want to track the events using Smartech base SDK, please follow steps given here

Using CleverTap

If you want to track the events using CleverTap SDK, you can do that in a few easy steps.

public static void push(CleverTapAPI clevertapAPI, String eventName, HashMap<String, Object> properties) {
        //Please pass the string "ctp" for vendor if you are using Clevertap to track the event.
        HashMap<String, String> hanselData = HanselTracker.logEvent(eventName, "ctp", properties);
        if (properties == null) {
            properties = new HashMap<>();
        }
        properties.putAll(hanselData);

        clevertapAPI.event.push(eventName, properties);
    }
fun push(clevertapAPI: CleverTapAPI, eventName: String, properties: HashMap<String, Any>?) {
        var properties = properties
        //Please pass the string "ctp" for vendor if you are using Clevertap to track the event.
        val hanselData = HanselTracker.logEvent(eventName, "ctp", properties)
        if (properties == null) {
            properties = HashMap()
        }
        properties.putAll(hanselData)

        clevertapAPI.event.push(eventName, properties)
    }
import {NativeModules} from 'react-native';

var AppCleverTap = (function () {
  function logEvent(eventName, properties) {
    var mergedProperties = {};
    NativeModules.HanselTrackerRn.logEvent(eventName,"ctp",properties,(hanselData) => {
        if(!properties) {properties = {};}
        mergedProperties = Object.assign(properties, hanselData);   
        CleverTap.recordEvent(eventName, mergedProperties);
    });
  }
})();

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

//If the original code was
CleverTapAPI.getInstance(context).event.push(eventName, properties);

//it would get updated to
AppCleverTap.push(CleverTapAPI.getInstance(context), eventName, properties);
//If the original code was
CleverTapAPI.getInstance(context).event.push(eventName, properties)

//it would get updated to
AppCleverTap.push(CleverTapAPI.getInstance(context), eventName, properties)
//If the original code was
CleverTap.recordEvent(eventName, properties);

//it would get updated to
AppCleverTap.logEvent(eventName, properties);

Using Mixpanel

If you want to track the events using Mixpanel SDK, you can do that in a few easy steps.

Step 1: Create a new class "AppMixpanel" and add the following method to it.

public static void track(MixpanelAPI mixPanel, String eventName, JSONObject properties) {
        if (properties == null) {
            properties = new JSONObject();
        }
        HashMap<String, Object> propertiesMap = new HashMap<>();
        for (Iterator<String> it = properties.keys(); it.hasNext(); ) {
            String key = it.next();
            propertiesMap.put(key, properties.opt(key));
        }
        //Please pass the string "mxp" for vendor if you are using Mixpanel to track the event.
        HashMap<String, String> hanselData = HanselTracker.logEvent(eventName, "mxp", propertiesMap);
        for (String key : hanselData.keySet()) {
            try {
                properties.put(key, hanselData.get(key));
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        mixPanel.track(eventName, properties);
    }
fun track(mixPanel: MixpanelAPI, eventName: String, properties: JSONObject?) {
        var properties = properties
        if (properties == null) {
            properties = JSONObject()
        }
        val propertiesMap = HashMap<String, Any>()
        val it = properties.keys()
        while (it.hasNext()) {
            val key = it.next()
            propertiesMap[key] = properties.opt(key)
        }
        //Please pass the string "mxp" for vendor if you are using Mixpanel to track the event.
        val hanselData = HanselTracker.logEvent(eventName, "mxp", propertiesMap)
        for (key in hanselData.keys) {
            try {
                properties.put(key, hanselData[key])
            } catch (e: JSONException) {
                e.printStackTrace()
            }

        }
        mixPanel.track(eventName, properties)
    }
import {NativeModules} from 'react-native';

var AppMixPanel = (function () {
  function track(eventName, properties) {
    var mergedProperties = {};
    NativeModules.HanselTrackerRn.logEvent(eventName,"mxp",properties,(hanselData) => {
        if(!properties) {properties = {};}
        mergedProperties = Object.assign(properties, hanselData);   
        MixPanel.track(eventName, mergedProperties);
    });
  }
})();

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

//If the original code was
mixPanel.track(eventName, properties);

//it would get updated to
AppMixPanel.track(mixPanel, eventName, properties);
//If the original code was
mixPanel.track(eventName, properties)

//it would get updated to
AppMixPanel.track(eventName, properties)
//If the original code was
MixPanel.track(eventName, properties);

//it would get updated to
AppMixPanel.track(eventName, properties);

Using Amplitude

If you want to track the events using Amplitude SDK, you can do that in a few easy steps.

Step 1: Create a new class "AppAmplitude" and add the following method to it.

public static void logEvent(AmplitudeClient amplitudeClient, String eventName, JSONObject properties) {

        if (properties == null) {
            properties = new JSONObject();
        }
        HashMap<String, Object> propertiesMap = new HashMap<>();
        for (Iterator<String> it = properties.keys(); it.hasNext(); ) {
            String key = it.next();
            propertiesMap.put(key, properties.opt(key));
        }
        //Please pass the string "amp" for vendor if you are using Amplitude to track the event.
        HashMap<String, String> hanselData = HanselTracker.logEvent(eventName, "amp", propertiesMap);
        if (hanselData != null) {
            for (String key : hanselData.keySet()) {
                try {
                    properties.put(key, hanselData.get(key));
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }

        amplitudeClient.logEvent(eventName, properties);
    }
fun logEvent(amplitudeClient: AmplitudeClient, eventName: String, properties: JSONObject?) {
        var properties = properties

        if (properties == null) {
            properties = JSONObject()
        }
        val propertiesMap = HashMap<String, Any>()
        val it = properties.keys()
        while (it.hasNext()) {
            val key = it.next()
            propertiesMap[key] = properties.opt(key)
        }
        //Please pass the string "amp" for vendor if you are using Amplitude to track the event.
        val hanselData = HanselTracker.logEvent(eventName, "amp", propertiesMap)
        if (hanselData != null) {
            for (key in hanselData.keys) {
                try {
                    properties.put(key, hanselData[key])
                } catch (e: JSONException) {
                    e.printStackTrace()
                }

            }
        }

        amplitudeClient.logEvent(eventName, properties)
    }
import {NativeModules} from 'react-native';

var AppAmplitude = (function () {
  function logEvent(amplitudeClient, eventName, properties) {
    var mergedProperties = {};
    NativeModules.HanselTrackerRn.logEvent(eventName,"amp",properties,(hanselData) => {
        if(!properties) {properties = {};}
        mergedProperties = Object.assign(properties, hanselData);   
        amplitudeClient.logEvent(eventName, mergedProperties);
    });
  }
})();

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

//If the original code was
amplitudeClient.logEvent(eventName, properties);

//it would get updated to
AppAmplitude.logEvent(amplitudeClient, eventName, properties);
//If the original code was
amplitudeClient.logEvent(eventName, properties)

//it would get updated to
AppAmplitude.logEvent(amplitudeClient, eventName, properties)
//If the original code was
amplitudeClient.logEvent(eventName, mergedProperties);

//it would get updated to
AppAmplitude.logEvent(amplitudeClient, eventName, properties);

Using Segment

If you want to track the events using Segment SDK, you can do that in a few easy steps.

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

public static void track(Analytics analytics, String eventName, Properties properties) {
        if (properties == null) {
            properties = new Properties();
        }
        HashMap<String, Object> propertiesMap = new HashMap<>(properties);
        //Please pass the string "smt" for vendor if you are using Segment to track the event.
        HashMap<String, String> hanselData = HanselTracker.logEvent(eventName, "smt", propertiesMap);
        for (String key : hanselData.keySet()) {
            properties.put(key, hanselData.get(key));
        }

        analytics.track(eventName, properties);
    }
fun track(analytics: Analytics, eventName: String, properties: Properties?) {
        var properties = properties
        if (properties == null) {
            properties = Properties()
        }
        val propertiesMap = HashMap(properties)
        //Please pass the string "smt" for vendor if you are using Segment to track the event.
        val hanselData = HanselTracker.logEvent(eventName, "smt", propertiesMap)
        for (key in hanselData.keys) {
            properties[key] = hanselData[key]
        }

        analytics.track(eventName, properties)
    }
import {NativeModules} from 'react-native';

var AppSegment = (function () {
  function track(segmentClient, eventName, properties) {
    var mergedProperties = {};
    NativeModules.HanselTrackerRn.logEvent(eventName,"smt",properties,(hanselData) => {
        if(!properties) {properties = {};}
        mergedProperties = Object.assign(properties, hanselData);   
        segmentClient.track(eventName, mergedProperties);
    });
  }
})();

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

//If the original code was
Analytics.with(context).track(eventName, properties);

//it would get updated to
AppSegment.track(Analytics.with(context), eventName, properties);
//If the original code was
Analytics.with(context).track(eventName, properties);

//it would get updated to
AppSegment.track(Analytics.with(context), eventName, properties);
//If the original code was
segmentClicnet.track(eventName, properties);

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

Using Firebase

If you want to track the events using Firebase SDK, you can do that in a few easy steps.

Step 1: Create a new class "AppFirebase" and add the following method to it.

public static void logEvent(FirebaseAnalytics firebaseAnalytics, String eventName, Bundle properties) {
        if (properties == null) {
            properties = new Bundle();
        }
        HashMap<String, Object> propertiesMap = new HashMap<>();
        for (String key : properties.keySet()) {
            propertiesMap.put(key, properties.get(key));
        }
        //Please pass the string "fbs" for vendor if you are using Firebase to track the event.
        HashMap<String, String> hanselData = HanselTracker.logEvent(eventName, "fbs", propertiesMap);
        for (String key : hanselData.keySet()) {
            properties.putString(key, hanselData.get(key));
        }
        firebaseAnalytics.logEvent(eventName, properties);
    }
fun logEvent(firebaseAnalytics: FirebaseAnalytics, eventName: String, properties: Bundle?) {
        var properties = properties
        if (properties == null) {
            properties = Bundle()
        }
        val propertiesMap = HashMap<String, Any>()
        for (key in properties.keySet()) {
            propertiesMap[key] = properties.get(key)
        }
        //Please pass the string "fbs" for vendor if you are using Firebase to track the event.
        val hanselData = HanselTracker.logEvent(eventName, "fbs", propertiesMap)
        for (key in hanselData.keys) {
            properties.putString(key, hanselData[key])
        }
        firebaseAnalytics.logEvent(eventName, properties)
    }
import {NativeModules} from 'react-native';

var AppFirebase = (function () {
  function logEvent(firebaseClient, eventName, properties) {
    var mergedProperties = {};
    NativeModules.HanselTrackerRn.logEvent(eventName,"fbs",properties,(hanselData) => {
        if(!properties) {properties = {};}
        mergedProperties = Object.assign(properties, hanselData); 
        firebaseClient.logEvent(eventName, mergedProperties);
    }); 
  }
})();

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

//If the original code was
FirebaseAnalytics.getInstance(context).logEvent(eventName, properties);

//it would get updated to
AppFirebase.logEvent(FirebaseAnalytics.getInstance(context), eventName, properties);
//If the original code was
FirebaseAnalytics.getInstance(context).logEvent(eventName, properties);

//it would get updated to
AppFirebase.logEvent(FirebaseAnalytics.getInstance(context), eventName, properties);
//If the original code was
firebaseClient.logEvent(eventName, properties);

//it would get updated to
AppFirebase.logEvent(firebaseClient, eventName, properties);

Using Omniture

If you want to track the events using Omniture SDK, you can do that in a few easy steps.

Step 1: Create a new class "AppOmniture" and add the following methods to it.

public static void trackAction(String eventName, HashMap<String, Object> properties) {
        //Please pass the string "omni" for vendor if you are using Omniture to track the event.
        HashMap<String, String> hanselData = HanselTracker.logEvent(eventName, "omni", properties);
        if (properties == null) {
            properties = new HashMap<>();
        }
        properties.putAll(hanselData);
        Analytics.trackAction(eventName, properties);
    }

    public static void trackState(String eventName, HashMap<String, Object> properties) {
        //Please pass the string "omni" for vendor if you are using Omniture to track the event.
        HashMap<String, String> hanselData = HanselTracker.logEvent(eventName, "omni", properties);
        if (properties == null) {
            properties = new HashMap<>();
        }
        properties.putAll(hanselData);
        Analytics.trackState(eventName, properties);
    }
fun trackAction(eventName: String, properties: HashMap<String, Any>) {
        //Please pass the string "omni" for vendor if you are using Omniture to track the event.
        val hanselData = HanselTracker.logEvent(eventName, "omni", properties)
        properties.putAll(hanselData)
        Analytics.trackAction(eventName, properties)
    }

    fun trackState(eventName: String, properties: HashMap<String, Any>) {
        //Please pass the string "omni" for vendor if you are using Omniture to track the event.
        val hanselData = HanselTracker.logEvent(eventName, "omni", properties)
        properties.putAll(hanselData)
        Analytics.trackState(eventName, properties)
    }
import {NativeModules} from 'react-native';

var AppOmniture = (function () {
  function trackAction(omnitureClient, eventName, properties) {
    var mergedProperties = {};
    NativeModules.HanselTrackerRn.logEvent(eventName,"omni",properties,(hanselData) => {
        if(!properties) {properties = {};}
        mergedProperties = Object.assign(properties, hanselData);   
    });
    omnitureClient.trackAction(eventName, mergedProperties);
  }
  
  function trackState(omnitureClient, eventName, properties) {
    var mergedProperties = {};
    NativeModules.HanselTrackerRn.logEvent(eventName,"omni",properties,(hanselData) => {
        if(!properties) {properties = {};}
        mergedProperties = Object.assign(properties, hanselData);   
        omnitureClient.trackState(eventName, mergedProperties);
    });
  }
})();

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

//If the original code was
Analytics.trackAction(eventName, properties);
//or
Analytics.trackState(eventName, properties);

//it would get updated to
AppOmniture.trackAction(eventName, properties);
//or
AppOmniture.trackState(eventName, properties);
//If the original code was
Analytics.trackAction(eventName, properties);
//or
Analytics.trackState(eventName, properties);

//it would get updated to
AppOmniture.trackAction(eventName, properties);
//or
AppOmniture.trackState(eventName, properties);
//If the original code was
omnitureClient.trackAction(eventName, properties);
//or
omnitureClient.trackState(eventName, properties);

//it would get updated to
AppOmniture.trackAction(omnitureClient, eventName, properties);
//or
AppOmniture.trackState(omnitureClient, eventName, properties);

Using Google Analytics

If you want to track the events using Google Analytics SDK, you can do that in a few easy steps.

Step 1: Create a new class "AppGA" and add the following methods to it.

public static void send(Tracker tracker, HitBuilders.EventBuilder eventBuilder,
                            String category, String action, String label, HashMap<String, Object> properties) {
        if (eventBuilder == null) {
            eventBuilder = new HitBuilders.EventBuilder().setCategory(category).setAction(action).setLabel(label);
        }
        String eventName = getEventNameForGa(category, action, label);

        //Please pass the string "ga" for vendor if you are using Google Analytics to track the event.
        HashMap<String, String> hanselData = HanselTracker.logEvent(eventName, "ga", properties);
        if (properties == null) {
            properties = new HashMap<>();
        }
        properties.putAll(hanselData);
        for (String key : properties.keySet()) {
            eventBuilder.set("&" + key, properties.get(key).toString());
        }
        tracker.send(eventBuilder.build());
    }

    private static String getEventNameForGa(String category, String action, String label) {
        String eventName = "";
        if (category!=null) {
            eventName += category;
        }

        if (action!=null) {
            if (eventName.length() > 0) {
                eventName += "_" + action;
            } else {
                eventName += action;
            }
        }
      
        if (label!=null) {
            if (eventName.length() > 0) {
                eventName += "_" + label;
            } else {
                eventName += label;
            }
        }

        return eventName;
    }
fun send(tracker: Tracker, eventBuilder: HitBuilders.EventBuilder?,
             category: String, action: String, label: String, properties: HashMap<String, Any>?) {
        var eventBuilder = eventBuilder
        var properties = properties
        if (eventBuilder == null) {
            eventBuilder = HitBuilders.EventBuilder().setCategory(category).setAction(action).setLabel(label)
        }
        val eventName = getEventNameForGa(category, action, label)

        //Please pass the string "ga" for vendor if you are using Google Analytics to track the event.
        val hanselData = HanselTracker.logEvent(eventName, "ga", properties)
        if (properties == null) {
            properties = HashMap()
        }
        properties.putAll(hanselData)
        for (key in properties.keys) {
            eventBuilder!!.set("&$key", properties[key]!!.toString())
        }
        tracker.send(eventBuilder!!.build())
    }

    private fun getEventNameForGa(category: String, action: String, label: String): String {
        var eventName = ""
        if (HSLUtils.isSet(category)) {
            eventName += category
        }

        if (HSLUtils.isSet(action)) {
            if (eventName.length > 0) {
                eventName += "_$action"
            } else {
                eventName += action
            }
        }

        return eventName
    }

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

//If the original code was
HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
           .setCategory(category)
           .setAction(action)
           .setLabel(label)
           .set("<property_key>", "<property_value>")
           .set("<property_key>", "<property_value>");
gaTracker.send(eventBuilder.build());

//it would get updated to
HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
           .setCategory(category)
           .setAction(action)
           .setLabel(label)
           .set("<property_key>", "<property_value>")
           .set("<property_key>", "<property_value>");
AppGA.send(gaTracker, eventBuilder, category, action, label);
//If the original code was
val eventBuilder: HitBuilders.EventBuilder = HitBuilders.EventBuilder()
           .setCategory(category)
           .setAction(action)
           .setLabel(label)
           .set("<property_key>", "<property_value>")
           .set("<property_key>", "<property_value>")
gaTracker.send(eventBuilder.build())

val eventBuilder: HitBuilders.EventBuilder = HitBuilders.EventBuilder()
           .setCategory(category)
           .setAction(action)
           .setLabel(label)
           .set("<property_key>", "<property_value>")
           .set("<property_key>", "<property_value>")
AppGA.send(gaTracker, eventBuilder, category, action, label)
//If the original code was
HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
           .setCategory(category)
           .setAction(action)
           .setLabel(label)
           .set("<property_key>", "<property_value>")
           .set("<property_key>", "<property_value>");
gaTracker.send(eventBuilder.build());

//it would get updated to
HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
           .setCategory(category)
           .setAction(action)
           .setLabel(label)
           .set("<property_key>", "<property_value>")
           .set("<property_key>", "<property_value>");
AppGA.send(gaTracker, eventBuilder, category, action, label);

Using Localytics

If you want to track the events using Localytics SDK, you can do that in a few easy steps.

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

public static void tagEvent(String eventName, HashMap<String, Object> properties) {
        //Please pass the string "loca" for vendor if you are using Localytics to track the event.
        HashMap<String, String> hanselData = HanselTracker.logEvent(eventName, "loca", properties);
        if (properties == null) {
            properties = new HashMap<>();
        }
        properties.putAll(hanselData);

        Localytics.tagEvent(eventName, properties);
    }
fun tagEvent(eventName: String, properties: HashMap<String, Any>?) {
        var properties = properties
        //Please pass the string "loca" for vendor if you are using Localytics to track the event.
        val hanselData = HanselTracker.logEvent(eventName, "loca", properties)
        if (properties == null) {
            properties = HashMap()
        }
        properties.putAll(hanselData)

        Localytics.tagEvent(eventName, properties)
    }
import {NativeModules} from 'react-native';

var AppLocalytics = (function () {
  function tagEvent(localyticsClient, eventName, properties) {
    var mergedProperties = {};
    NativeModules.HanselTrackerRn.logEvent(eventName,"loca",properties,(hanselData) => {
        if(!properties) {properties = {};}
        mergedProperties = Object.assign(properties, hanselData);   
        localyticsClient.tagEvent(eventName, mergedProperties);
    });
  }
})();

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

//If the original code was
Localytics.tagEvent(eventName, properties)

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

//it would get updated to
AppLocalytics.tagEvent(eventName, properties);
//If the original code was
localyticsClient.tagEvent(eventName, properties)

//it would get updated to
AppLocalytics.tagEvent(localyticsClient, eventName, properties);

Using WebEngage

If you want to track the events using WebEngage SDK, you can do that in a few easy steps.

Step 1: Create a new class "AppWebEngage" and add the following method to it.

public static void track(Analytics weAnalytics, String eventName, HashMap<String, Object> properties) {

        //Please pass the string "wbe" for vendor if you are using WebEngage to track the event.
        HashMap<String, String> hanselData = HanselTracker.logEvent(eventName, "wbe", properties);
        if (properties == null) {
            properties = new HashMap<>();
        }
        properties.putAll(hanselData);
        weAnalytics.track(eventName, properties);
    }
fun track(weAnalytics: Analytics, eventName: String, properties: HashMap<String, Any>?) {
        var properties = properties

        //Please pass the string "wbe" for vendor if you are using WebEngage to track the event.
        val hanselData = HanselTracker.logEvent(eventName, "wbe", properties)
        if (properties == null) {
            properties = HashMap()
        }
        properties.putAll(hanselData)
        weAnalytics.track(eventName, properties)
    }
import {NativeModules} from 'react-native';

var AppWebEngage = (function () {
  function track(webEngageClient, eventName, properties) {
    var mergedProperties = {};
    NativeModules.HanselTrackerRn.logEvent(eventName,"wbe",properties,(hanselData) => {
        if(!properties) {properties = {};}
        mergedProperties = Object.assign(properties, hanselData);   
        webEngageClient.track(eventName, mergedProperties);
    });
  }
})();

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

//If the original code was
weAnalytics.track(eventName, properties);

//it would get updated to
AppWebEngage.track(weAnalytics, eventName, properties);
//If the original code was
weAnalytics.track(eventName, properties)

//it would get updated to
AppWebEngage.track(weAnalytics, eventName, properties)
//If the original code was
webEngageClient.track(eventName, properties);

//it would get updated to
AppWebEngage.track(webEngageClient, eventName, properties);

Other Analytics Providers

If you use an analytics provider other than the ones mentioned above, please reach out to us at [email protected]

Using Hansel to fire custom events

If you want to track the events using Hansel, you can do that in a few easy steps.

Step 1: Create a new class "AppHansel" and add the following method to it.

public static void logEvent(String eventName, HashMap<String, Object> properties) {
        //Please pass the string "hsl" for vendor if you are using Hansel to track the event.
        HashMap<String, String> hanselData = HanselTracker.logEvent(eventName, "hsl", properties);
    }
fun track(eventName: String, properties: HashMap<String, Any>?) {
        var properties = properties

        //Please pass the string "hsl" for vendor if you are using Hansel to track the event.
        val hanselData = HanselTracker.logEvent(eventName, "hsl", properties)
    }
import {NativeModules} from 'react-native';

var AppHansel = (function () {
  function track(eventName, properties) {
    NativeModules.HanselTrackerRn.logEvent(eventName,"hsl",properties,(hanselData) => {
    });
  }
})();

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

AppHansel.track(eventName, properties);
AppHansel.track(eventName, properties)
AppHansel.track(eventName, properties);

Fire events from Test device:

Ensure that you fire the events which you added in Steps 1 and 2, from a test device. This can be done by invoking all the flows within the app, where the events have been added. To learn more on setting up test device, please click here.

Once you have done the above changes, selected events will contain information related to the interaction maps created on Hansel dashboard.

Setting up page load events

You may use page load/page view events as triggers for Display Nudges. To reliably use these events as triggers, ensure that your event is fired post rendering the Activity. Use the following code snippet to fire page load events in the right methods.

🚧

Page load events for dynamic screens

In case if the App needs to make an API call to fetch the data before rendering the screen. Then please trigger the page load once the API call returns and the screen is completed rendered.

@Override
protected void onResume() {
   super.onResume();
   //Trigger the event here with a delay. 
   //The delay is to make sure the screen is completely rendered when the event is triggered.
  long delay = 2000;
  Handler handler = new Handler(context.getMainLooper());
  handler.postDelayed(new Runnable() {
      @Override
        public void run() {
        //Track event here.
      }
   },delay);
}

In case your page load events are not in the above format, you may either modify it or fire a new Hansel event in onResume() method of the Activity or the Fragment (in case you do not wish to modify the existing event).