Send nudge events to your own analytics system

Please follow the steps below to get nudge events shared with your analytics system. This listener will provide following events:

  1. hansel_nudge_show_event - This event will be fired when a nudge is rendered on the device. This is available from Android Product Experience SDK v8.6.3 onwards only.
  2. hansel_nudge_event - This event will be fired when the nudge is dismissed. This is available from Android Product Experience SDK v8.5.0 onwards.
  3. hansel_branch_tracker - This event will be fired whenever the user moves in/out of any branch or segment. This is available from Android Product Experience SDK v9.0.7 onwards. Below are the cases in which this callback is invoked :
    • SDK initialisation
    • User identity change
    • Segment(Positive/Negative) change

Step 1 : Create a class that implements the HanselInternalEventsListener with the following method:

import io.hansel.ujmtracker.HanselInternalEventsListener;

HanselInternalEventsListener hanselInternalEventsListener = new HanselInternalEventsListener() {
   @Override
   public void onEvent(String eventName, HashMap dataFromHansel) {
        if ("hansel_nudge_show_event".equals(eventName)) {
	        // Invokes when nudge is shown to the user where "Send the event to Analytics provider" is enabled for the nudge
            // send `dataFromHansel` to your analytics provider 
            // e.g. CleverTap.push(clevertapAPI, "hansel_nudge_show_event", dataFromHansel);
        } 
	    else if ("hansel_nudge_event".equals(eventName)) {
	        // Invokes when nudge is dismissed from the device where "Send the event to Analytics provider" is enabled for the nudge
            // send `dataFromHansel` to your analytics provider 
            // e.g. CleverTap.push(clevertapAPI, "hansel_nudge_event", dataFromHansel);
        }
	    else if ("hansel_branch_tracker".equals(eventName)) {
	        // Invokes when user branch is changed or initial state of the branches gets synced
            // send `dataFromHansel` to your analytics provider 
            // e.g. CleverTap.push(clevertapAPI, "hansel_branch_tracker", dataFromHansel);
        }
    }
};
import io.hansel.ujmtracker.HanselInternalEventsListener

var hanselInternalEventsListener: HanselInternalEventsListener =
            HanselInternalEventsListener { eventName, dataFromHansel ->
                when (eventName) {
                    "hansel_nudge_show_event" -> {
                        // Invokes when nudge is shown to the user where "Send the event to Analytics provider" is enabled for the nudge
                        // send `dataFromHansel` to your analytics provider
                        // e.g. CleverTap.push(clevertapAPI, "hansel_nudge_show_event", dataFromHansel);
                    }
                    "hansel_nudge_event" -> {
                        // Invokes when nudge is dismissed from the device where "Send the event to Analytics provider" is enabled for the nudge
                        // send `dataFromHansel` to your analytics provider
                        // e.g. CleverTap.push(clevertapAPI, "hansel_nudge_event", dataFromHansel);
                    }
                    "hansel_branch_tracker" -> {
                        // Invokes when user branch is changed or initial state of the branches gets synced
                        // send `dataFromHansel` to your analytics provider
                        // e.g. CleverTap.push(clevertapAPI, "hansel_branch_tracker", dataFromHansel);
                    }
                }
            }

Step 2 : Registering the listener with Product Experience SDK

import io.hansel.ujmtracker.HanselTracker;

//Register the listener with Hansel SDK by using this code.
HanselTracker.registerListener(hanselInternalEventsListener);
import io.hansel.ujmtracker.HanselTracker

//Register the listener with Hansel SDK by using this code.
HanselTracker.registerListener(hanselInternalEventsListener)

Note

  1. Please ensure to select the checkbox 'Send nudges to Analytics Provider' from Step 2 of Nudge creation flow for hansel_nudge_show_event & hansel_nudge_event
  2. Please note that this step is not required for hansel_branch_tracker call back

  1. Below are properties that you can expect in these following events.

hansel_nudge_show_event

  • interaction_map_name
  • nudge_name
  • nudge_type
  • app_id
  • user_id (fallback to device id if not present)

hansel_nudge_event

  • interaction_map_name
  • nudge_name
  • nudge_type
  • app_id
  • user_id (fallback to device id if not present)
  • nudge_rating : NULL | Rating | NPS (will be a number)
  • nudge_mcq : MCQ (will be a string)
  • nudge_inputtext: NULL | text
  • nudge_action: button1/2_clicked | buttontext | close_clicked | noaction_autodismissed | noaction_screenchanged | noaction_appclosed | backdrop_dismissed

hansel_branch_tracker

  • hsl_counter -> integer value that represents the number of hsl_data present in dataFromHansel map. For example hsl_counter = 3 means hsl_data, hsl_data1 and hsl_data2 should be available in map
  • hsl_data
    hsl_data1
    hsl_data2
  • hsl_ven -> represents analytics vendor used for the SDK.

Next

For more information, visit this link.