MoEngage Docs

SDK Callbacks

MoEngage provides you the behavioural data only for the users who opt in for push notifications. So, if you are trying to optimise the opt in funnel, and check the exact stats on how many users have agreed/blocked to subscribing for push notifications, you will have to track it as part of your existing analytics solution.

To achieve this, we have exposed certain opt-in interaction events that can be listened to and you can track them using your own analytics flow.

Chrome's Default Opt-in

Chrome's Default Opt-in

Sample Custom Opt-in

Sample Custom Opt-in

Detailed Reference for opt-in interaction callbacks :

Detailed Reference for Opt-in interaction Callbacks

Event listener syntax:
window.addEventListener("MOE_OPT_IN",function(e){
//Track events here
});

Name of the Event - MOE_OPT_IN

Type of events:

  • Default opt-in interaction events:

    • opt_in_shown - Default opt-in shown
    • opt_in_allowed - User clicked allow
    • opt_in_blocked - User clicked block
    • opt_in_dismissed - User dismissed the opt-in (clicked the cross icon)
  • Custom opt-in (Soft-Ask) interaction events:

    • soft_ask_shown - Custom opt-in shown
    • soft_ask_allowed - User accepted the opt-in
    • soft_ask_closed - User dismissed the opt-in

This is how you can add listeners for the events mentioned above.

//Tracking events for Chrome's Default Opt-in and for Custom Opt-in

window.addEventListener("MOE_OPT_IN",function(e){
        if(e.detail === "opt_in_shown"){
          // Default opt-in shown
          // Put your tracking code here.
        }
        else if(e.detail === "opt_in_allowed"){
          //User clicked "Allow" button
          // Put your tracking code here.
        }
        else if(e.detail === "opt_in_blocked"){
          //User clicked "Block" button        
          // Put your tracking code here.
        }
        else if(e.detail === "opt_in_dismissed"){
          //User clicked the cross button (dismissed the prompt)
          // Put your tracking code here.
        }

        //Tracking Custom opt-in/Soft Ask interactions
        else if(e.detail === "soft_ask_shown"){
          //Custom opt-in shown
          // Put your tracking code here.
        }
        else if(e.detail === "soft_ask_allowed"){
          //User accepted the opt-in
          // Put your tracking code here.
        }
        else if(e.detail === "soft_ask_closed"){
          //User dismissed the opt-in
          // Put your tracking code here.
        }

        //Prints the event that occured
        console.log("MOE_OPT_IN : ", e.detail);
});

SDK Callbacks


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.