Configuring Analytics via Webengage
Step 1: Create new Class
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, Object> 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: Tracking Hansel changes
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);
Updated 6 months ago