Define a Custom Callback

Understand the pre-configuration required to track notification views and clicks

Define a Custom Callback

Using the following custom callback functions, you can control the look, feel, and location of your web pop-up.

You need to explicitly call clevertap.raiseNotificationViewed(); and clevertap.raiseNotificationClicked(); to ensure that notification views and clicks are tracked on CleverTap.

To define the callback and raise the clicked and viewed events, you need to add the following snippet to the JavaScript embed code comprising your CleverTap web integration:

clevertap.notificationCallback = function(msg){
      // Raise the notification viewed and clicked events in the callback
      console.log(JSON.stringify(msg));// Your custom rendering implementation here
      var $button = jQuery("<button></button>");// Element on whose click you want to raise the notification clicked event

The message will be in the following format:

    "msgContent": {
        "title": "hello title!",
        "description": “hello message!"
    "msgId": "1439796272_20160219",
    "kv": {

msgId contains the campaign ID and the date-stamp so that you can programmatically decide whether to display the notification. kv contains the custom key value pairs.

Did this page help you?