Copied To Clipboard

Integration

IMPORTANT :

This is one time integration code for On-site Notifications, Surveys, Push engagements, AB Testing and Heatmaps. If you have already included this in your head section, no need to put it again.

We also provide PLUGINS for popular CMS like wordpress, shopify, opencart, GTM and many more.Go To Plugins Section

  • Javascript

    
    <script>
        var nv=nv||function(){(window.nv.q=window.nv.q||[]).push(arguments)};nv.l=new Date;var notify_visitors=notify_visitors||function(){
        var e={initialize:!1,ab_overlay:!1,auth:{ bid_e:"85430CD4791E9660F94D2726ACCF920E",bid:"52X",t:"420"}};
        return e.data={bid_e:e.auth.bid_e,bid:e.auth.bid,t:e.auth.t,iFrame:window!==window.parent,trafficSource:document.referrer,link_referrer:document.referrer,pageUrl:document.location,path:location.pathname,domain:location.origin,gmOffset:60*(new Date).getTimezoneOffset()*-1,screenWidth:screen.width,screenHeight:screen.height,isPwa:window.matchMedia("(display-mode: standalone)").matches?1:0,cookieData:document.cookie},e.options=function(t){t&&"object"==typeof t?e.ab_overlay=t.ab_overlay:console.log("Not a valid option")},e.tokens=function(t){e.data.tokens=t&&"object"==typeof t?JSON.stringify(t):""},e.ruleData=function(t){e.data.ruleData=t&&"object"==typeof t?JSON.stringify(t):""},e.getParams=function(e){url=window.location.href.toLowerCase(),e=e.replace(/[\[\]]/g,"\\$&").toLowerCase();var t=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(url);return t&&t[2]?decodeURIComponent(t[2].replace(/\+/g," ")):""},e.init=function(){if(e.auth&&!e.initialize&&(e.data.storage=e.browserStorage(),e.js_callback="nv_json1",!e.data.iFrame&&"noapi"!==e.getParams("nvcheck"))){var t="?";if(e.ab_overlay){var o=document.createElement("style"),n="body{opacity:0 !important;filter:alpha(opacity=0) !important;background:none !important;}",a=document.getElementsByTagName("head")[0];o.setAttribute("id","_nv_hm_hidden_element"),o.setAttribute("type","text/css"),o.styleSheet?o.styleSheet.cssText=n:o.appendChild(document.createTextNode(n)),a.appendChild(o),setTimeout(function(){var e=this.document.getElementById("_nv_hm_hidden_element");if(e)try{e.parentNode.removeChild(e)}catch(t){e.remove()}},2e3)}for(var i in e.data)e.data.hasOwnProperty(i)&&(t+=encodeURIComponent(i)+"="+encodeURIComponent(e.data[i])+"&");e.load("https://www.notifyvisitors.com/ext/v1/settings"+t),e.initialize=!0}},e.browserStorage=function(){var t={session:e.storage("sessionStorage"),local:e.storage("localStorage")};return JSON.stringify(t)},e.storage=function(e){var t={};return window[e].length>0&&Object.keys(window[e]).forEach(function(o){-1!==o.indexOf("_nv_")&&(t[o]=window[e][o])}),t},e.load=function(e){var t=document,o=t.createElement("script");o.src=e,o.type="text/javascript",t.body?t.body.appendChild(o):t.head.appendChild(o)},e}();
        
        notify_visitors.init();
    </script>

    

Send optional parameters (place just before notify_visitors.init() method)

  • Optional Parameters

     
        notify_visitors.options({
            ab_overlay: true //to enable or disable the white overlay
        });
    

    

For dynamic tokens (place just before notify_visitors.init() method)

  • Dynamic Tokens

    
        notify_visitors.tokens({
            'key1': 'value1',
            'kay2': 'value2'
        });
    

    

To pass ruledata in custom targeting rules (place just before notify_visitors.init() method)

  • Ruledata

     
        notify_visitors.ruleData({
            'key1': 'value1',
            'key2': 'value2' 
        });
    

    

Web Push / PWA Integration

1. To integrate PWA / Web Push, you will need to add some files to your root folder.
Go to following link (https://push.notifyvisitors.com/brand/webapp/manifest) to configure and download the package.

On downloading the package, you should have :
  • notifyvisitors_push folder
  • service-worker.js

2. Place the files in root folder.

Upload the files to the top-level root of your site directory. All URLs should be publicly accessible:

https://yoursite.com/service-worker.js
https://yoursite.com/notifyvisitors_push/chrome/manifest.json

3. Add meta tags in header

Add these meta tags in tag.

<meta name="theme-color" content="#000">
<link rel="manifest" href="https://yoursite.com/notifyvisitors_push/chrome/manifest.json">

Track Users

User API enables you to track a users' activity as they move from device to device and attach attributes to their profiles. Attributes enrich user profiles, like email, username, mobile, gender etc. This method should be called when the user is identified (mostly on login).

  • Javascript

        nv('user', USER_ID, USER_ATTRIBUTES);      
        

USER_ID (string) - Setting the Unique ID is a critical piece to tie a user across devices and installs/uninstalls as well across all platforms (i.e. iOS, Android, Windows, The Web). Unique ID can be something like an email ID, a username (unique), or any Backend generated ID.

USER_ATTRIBUTES (JSON object) - You can set the user attributes like name, email, mobile number. These can then be used to send personalised content in notifications. But these attributes can not be used in segmenting the users.

Default Attribute Names -

  • name
  • email
  • mobile

You can also pass your custom attributes like username, birthday, first name, last name.

IMPORTANT :

Attribute Names should contain only alpha-numerics, white spaces or ‘_’ ;
No other special characters are allowed.
Recommended names - ‘first_name’, ‘last_name’
  • Javascript

        nv('user',‘1331’,{name:'John', email:'john@gmail.com', mobile:'+919899999999'});
        

Custom Dimensions

Custom dimensions are special fields that are used for storing user-level information like lead status (hot or cold), subscription (basic / standard / premium). Unlike user attributes, their value is updated in our database, if a new value is passed. These can be used in segmenting users and analytics.

IMPORTANT :

You can not pass any user identifiable information in dimensions like email, mobile
  • Javascript

        nv('dimensions', DIMENSION_NAME, DIMENSION_VALUE);   
        

DIMENSION_NAME (string) - Dimension Names should contain only alpha-numerics, white spaces or ‘_’ ; No other special characters are allowed.

DIMENSION_VALUE (string) - Dimension values can be any string value.

  • Javascript

        nv('dimensions', 'subscription', 'paid');
        

Track Events

Event API enables you to record any actions your users perform, along with any properties that describe the action. These are then used for analytics, user segmentation or to trigger engagements or other actions.

  • Javascript

        nv('event', EVENT_NAME, EVENT_ATTRIBUTES, LIFETIME_VALUE, SCOPE);   
        

EVENT_NAME (string) Name of the event like sale, register.
Event names should contain only alpha-numerics, white spaces or ‘_’ ; No other special characters are allowed.

EVENT_ATTRIBUTES (JSON object) Attributes associated with the event.
Attribute values should be passed in the form of Javascript strings, booleans and numbers respectively. Similarly date attribute values are expected in the form of Javascript date objects.

IMPORTANT :

Attribute Names should contain only alpha-numerics, white spaces or ‘_’ ;
No other special characters are allowed.
Recommended names - ‘category’, ‘price_usd’

LIFETIME_VALUE (integer) The score you would like to reward the user on performing this event like 10, 100.

SCOPE (integer)The scope of the event, whether it should be tracked every time it is called, or per session, or once in a lifetime. This parameter is used to minimise the duplication of data in analytics.
It is an integer whose values are :

  1. Track every time the api is called
  2. Track once per session
  3. Track once in a lifetime

  • Javascript

        nv('event','sale',{category:'Electronics', price_inr:'30000'},10,2);