MoEngage Docs

Search results for "{{ search.query }}"

No results found for "{{search.query}}". 
View All Results

Web Javascript SDK Setup

This section describes the integration of Web SDK on your website to track web user attributes and events. In case you are looking for Chrome/Firefox/Opera Push integration, proceed directly to the step-by-step integration flow.

Web SDK Integration

Include the below mentioned MoEngage Web SDK script inside the <head> tag of your website.

  • YOUR_APP_ID_GOES_HERE - Replace this with your account APP ID (find your APP ID on MoEngage Dashboard -> Settings -> App Settings)

  • debug_logs: 1 - This will enable you to see test data in TEST environment - accessed via clicking on toggle button in top bar on Dashboard. Read more about TEST/LIVE environment here

Note: In case you are using Google Tag Manager, you can refer to this section.

<script type="text/javascript">
(function(i,s,o,g,r,a,m){
i['moengage_object']=r;t={}; q = function(f){return function(){(i['moengage_q']=i['moengage_q']||[]).push({f:f,a:arguments});};};
f = ['track_event','add_user_attribute','add_first_name','add_last_name','add_email','add_mobile',
'add_user_name','add_gender','add_birthday','destroy_session','add_unique_user_id','moe_events','call_web_push','track'];
for(k in f){t[f[k]]=q(f[k]);}
a=s.createElement(o);m=s.getElementsByTagName(o)[0];a.async=1;a.crossOrigin='anonymous';a.src=g;m.parentNode.insertBefore(a,m);
i['moe']=i['moe'] || function(){n=arguments[0];return t;}; a.onload=function(){if(n){i[r] = moe(n);}};
})(window,document,'script','https://cdn.moengage.com/webpush/moe_webSdk.min.latest.js','Moengage'); 

Moengage = moe({
app_id:"YOUR_APP_ID_GOES_HERE",
debug_logs: 1
}); 
</script>

Before taking your website LIVE

In case you are taking your website live, DO ENSURE you pass debug_logs: 0 parameter to see Live data in LIVE environment on Dashboard otherwise your Live users will see an alert about the Test environment

Integration via Google Tag Manager (GTM)

You can also place the above SDK script and SDK initialization as a Custom HTML Tag inside GTM. This Tag can be fired once per page and fired on the pages where you wish to track web events/attributes.

You can next proceed to Tracking Website Events. This will help you to send segmented notifications/emails to avoid spamming and target only relevant users who did an event or share a common attribute (such as location).


Web Javascript SDK Setup