Configuring Analytics via Google Analytics

Step 1: Create a new service "AppGA" and add the following method to it.

var AppGA = (function () { function _send(hitType, category, action, label, value, properties) { var eventName = _getEventName(category, action, label); var mergedProperties = {}; //get the hansel experience's data var hanselData = Hansel.logEvent(eventName, "ga", properties); if(!properties) {properties = {};} mergedProperties = Object.assign(properties, hanselData); ga('send', { hitType: hitType, eventCategory: category, eventAction: action, eventLabel: label, eventValue: value, properties: mergedProperties }); } function _getEventName(category, action, label) { //You can change this logic to create a unique event name from category, action and label var eventName = (category || "") + (action || "") + (label || ""); return eventName; } return { send : _send } })();

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 ga('send', 'event', category, action, label, value, properties); //it would get updated to AppGA.send('event', category, action, label, value, 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 Google Analytics goal events will contain information related to the context charts created on Hansel dashboard.


Did this page help you?