Configuring Analytics via Segment
Step 1: Create a new service "AppSegment" and add the following method to it.
var AppSegment = (function () {
function _track(eventName, properties) {
var mergedProperties = {};
//get the hansel experience's data
var hanselData = Hansel.logEvent(eventName, "sgmt", properties);
if(!properties) {properties = {};}
mergedProperties = Object.assign(properties, hanselData);
analytics.track(eventName, mergedProperties);
}
return {
track : _track
};
})();
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.track(eventName, properties);
//it would get updated to
AppSegment.track(eventName, properties);
Step 3: 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 website, where the events have been added.
Once you have done the above changes, selected Segment goal events will contain information related to the context charts created on Hansel dashboard.
Updated 6 months ago