Google Tag Manager – Madrivo Pixel

This page describes how to install a Madrivo image pixel within GTM that passes back a Hit ID value.

Introduction
This implementation will create a Madrivo cookie that stores a Hit ID value throughout the user’s session. At the conversion, the Hit ID value is passed into an image pixel that is sent back to Madrivo.

Process

STEP 1: Login to GTM and select ‘Variables’ (Make sure that you’re working from within the right container)
STEP 2: Add a ‘New’ variable – variable type is URL
    • Component Type is ‘Query’
    • The Query Key is the url parameter assigned in the tracking link, example:
      • https://samplesite.com/landing-page?utm_term={{Hit_ID}}&utm_source=madrivo
      • Query Key = utm_term
    • Name this variable ‘Madrivo_Var_1’
    • Save
STEP 3: Select ‘Tags’ and add ‘New’
    • In this step, we are creating a cookie to store the Hit ID
    • Select a Tag Configuration of ‘Custom HTML’
    • Paste the following:
<script> 
var cookieName = "mhid"; // THIS IS THE NAME OF THE COOKIE - TO RECALL INTO THE IMAGE PIXEL LATER
var cookieValue = "{{Madrivo_Var_1}}"; // THIS SHOULD MATCH THE NAME OF THE URL QUERY VARIABLE
var cookiePath = "/"; // SAVE COOKIE TO DEFAULT DIRECTORY
var expirationTime = 86400000; // EXPIRES AFTER 1 DAY 
var date = new Date(); 
var dateTimeNow = date.getTime(); date.setTime(dateTimeNow + expirationTime);  // SET EXPIRATION DATE + TIME
var expirationTime = date.toUTCString(); // CONVERT DATE+TIME TO UTC
document.cookie = cookieName+"="+cookieValue+"; expires="+expirationTime+"; path="+cookiePath; //SET COOKIE
</script>
      • Note that the var cookieValue is defined as Madrivo_Var_1 from the variable assigned in step 2. The name of the variable in GTM must match for the cookie to capture the value of the Hit ID.
    • Add a Trigger to fire this Tag when a new user lands on the landing page. For example, if there is a url parameter that is specific to Madrivo related traffic, include that as a page view trigger to fire when Madrivo related traffic lands on the landing page. Example:
      • https://samplesite.com/landing-page?utm_term={{Hit_ID}}&utm_source=madrivo
      • Set the trigger to Page View, Some Page Views, Page URL contains ‘utm_source=madrivo’
      • Name the tag “Madrivo Cookie”
      • Save
STEP 4: Select ‘Variables’ and add ‘New’
    • Select the 1st Party Cookie option for this Variable Configuration
    • For the Cookie Name, enter ‘mhid’ (all lower case, no quotation marks)
    • Do not select URI-decode cookie
    • Name the variable “Madrivo_Var_2”
    • Save
STEP 5: Select ‘Tags’ and add ‘New’
    • In this step, we are creating the image pixel tag to fire the Hit ID value back to Madrivo
    • For Tag Configuration, select ‘Custom Image’
    • Add the URL for the pixel into the Image URL field, this URL is provided by Madrivo and unique to each campaign.
    • Select the ‘Madrivo_Var_2’ variable and add into the URL following the ‘hid=’ url parameter. Example:
      • https://www.pirolane.com/rd/px.php?hid={{Madrivo_Var_2}}&sid=1234
      • The image url will contain the stored Hit ID value assigned to Madrivo_Var_2. This value is passed back to Madrivo following ‘hid=’
      • The image URL should look similar to the example
      • Set the Trigger for this Tag to fire only when the conversion happens. The trigger will be specific to how you have setup the campaign with Madrivo. Find a unique trigger that will ensure that tag fires when the conversion happens.
      • Name the tag ‘Madrivo Image Pixel’
      • Save
FINAL STEPS
    • Submit and Publish the latest changes to GTM
    • Submit a test by using the Test Link provided by Madrivo
    • Notify Madrivo once the test was submitted
TROUBLESHOOTING
    • The best way to troubleshoot the tags, variables, and triggers are working is to use the Preview mode in GTM
    • Use the test link to generate a URL to add to the Preview mode testing. Using the test link as the preview URL will cause issues because of a redirect.
    • Common GTM issues
      • If you do not see the variable in preview mode, it is likely the wrong GTM container is installed on the site. Or, the tags were installed in the wrong instance of GTM
      • If the Madrivo_Var_1 value is undefined, try the following:
        • Check that the query value matches the value in the URL parameter of the tracking link
        • The trigger is set so the Madrivo Cookie tag will fire on the landing page
      • If the Madrivo_Var_2 value is undefined, try the following
        • Make sure that the 1st Party Cookie value is ‘mhid’, all lower case, no quotation marks.
      • If all variables are defined correctly, it is likely a trigger issue
        • Double check that the triggers are set with criteria that will cause the tag to fire as needed
    • Common testing issues
      • Be sure to test in an incognito window to ensure that existing cookies aren’t causing any issues.
      • Be sure to Submit and Publisher GTM once you have implemented the changes.
      • Complete all the steps to trigger a conversion
    • For more help, reach out to Madrivo to setup a screensharing session.