Advertiser Integration Guide
Direct Offer Conversion Tracking (OmniSDK + Google Tag Manager)
17min
overview this guide walks you through setting up conversion tracking with momentscience using google tag manager (gtm) prerequisites before you begin, ensure you have your momentscience account id your landing page urls your conversion page urls integration steps step 1 configure accountid data variable in gtm to ensure momentscience tracking works across all pages, you need to create a data layer variable for your account id in google tag manager , navigate to variables create a new variable of type data layer variable name it accountid check "set default value" and enter your momentscience account id as the default π this ensures your account id is accessible throughout your gtm setup step 2 add the momentscience omnisdk tag the momentscience omnisdk is required for tracking user interactions and conversions in gtm , go to tags and create a new tag of type custom html in the html field , enter the following omnisdk tag //π {{accountid}} references the data layer variable from step 1 \<script src="https //plugins pubtailer com/omnisdk js?accountid={{accountid}}">\</script> set the trigger to fire on all pages save and publish your changes β
this ensures that the omnisdk is loaded on every page of your site for tracking purposes step 3 implement click tracking on landing pages in gtm , create another tag of type custom html enter the following code \<script> // this code simply looks for a click identifier in the // url and saves to local cookie for later retrieval // on conversion handleadpxclickid(); \</script> set the tag firing option to once per page under tag sequencing , select "fire tag before " and choose the omnisdk tag from step 2 under triggers , configure the tag to fire only on landing pages π this tag ensures that click ids are properly captured for attribution step 4 implement conversion tracking on key event pages this step will guide you through setting up a custom html tag in gtm that fires only on pages where you want to track conversion events (e g , purchases, signups, or registrations) a create data layer variables for events before configuring the tag, we need to define two data layer variables to hold the event name (e g , conversion, purchase, lead) the event value (e g , the transaction amount) steps to create data layer variables in google tag manager (gtm) , go to variables β new create a data layer variable with the following settings variable name eventname set default value "conversion" create another data layer variable variable name amount set default value 0 when youβre done, you should have 3 user defined variables of type data layer π ensure these variables exist before proceeding to the next step b set up the conversion tracking tag in gtm , go to tags and create a new tag of type custom html enter the following javascript code \<script> (function() { var sale amount = {{amount}}; // replace with actual sale amount (if available) // main tracking //get mosci click id from cookie (captured on landing page // and saved local to site) var mosciclickid = getcookie('mosci click id'); var eventname = '{{eventname}}'; ///replace with actual event name trackmoscievent(mosciclickid, eventname, sale amount) then(function() { console log('tracking successful'); }) catch(function(error) { console error('tracking failed ', error); }); //alt tracking //get adpx click id from cookie var adpxclickid = getcookie('adpx click id'); trackevent(adpxclickid, sale amount) then(function() { console log('tracking successful'); }) catch(function(error) { console error('tracking failed ', error); }); })(); \</script> set the tag firing option to once per page under tag sequencing , select "fire tag before " and choose the omnisdk tag you set up in step 2 under triggers , configure the tag to fire only on conversion pages π this script tracks conversions by capturing stored click ids and sending them back to momentscience step 5 configure data layer variables on your website to ensure google tag manager (gtm) can correctly track conversions, you must pass data layer variables on your siteβs pages this section explains how to include these variables in your websiteβs \<head> section a configure data layer variables on landing pages on all landing pages, insert the following code above your gtm implementation in the \<head> tag \<script> window\ datalayer = window\ datalayer || \[]; datalayer push({ //π replace your account id with your actual momentscience account id 'accountid' 'your account id' }); \</script> this ensures that your account id is available in the data layer, allowing gtm to access it across different tracking tags b configure data layer variables on conversion pages on all conversion pages (e g , checkout success, registration complete), insert the following code above your gtm implementation in the \<head> tag \<script> window\ datalayer = window\ datalayer || \[]; datalayer push({ //π replace accountid with your actual momentscience account id 'accountid' 'your account id', //π replace event name with the actual event type (lead, cart, purchase, registration, etc ) 'eventname' 'event name', // π replace amount with the conversion value (if applicable) 'amount' 100 }); \</script> c handling multiple conversion events if your site includes multiple conversion events (e g , add to cart β purchase), repeat the data layer push on each relevant page for example cart page (/cart) β track when users add items to their cart \<script> window\ datalayer = window\ datalayer || \[]; datalayer push({ 'accountid' 'your account id', 'eventname' 'cart', 'amount' 0 }); \</script> purchase confirmation page (/thank you) β track completed purchases \<script> window\ datalayer = window\ datalayer || \[]; datalayer push({ 'accountid' 'your account id', 'eventname' 'purchase', 'amount' 250 }); \</script> a live working example can be found here final checklist step 1 accountid is configured as a data layer variable step 2 omnisdk tag is firing on all pages step 3 click tracking tag is firing only on landing pages step 4 conversion tracking tag is firing only on conversion pages step 5 data layer variables are implemented correctly on your website conclusion by following these steps, you have successfully integrated momentscience conversion tracking using google tag manager this setup ensures accurate tracking of user conversions while keeping your implementation scalable and flexible π’ if you're running into any issues while going through the integration process, feel free to contact us at help\@m omentscience com