How to add Eloqua tracking in Google Tag Manager

How to add Eloqua tracking in Google Tag Manager

Need to add an Eloqua (automated marketing software) tracking script to your website through Google Tag Manager?

If you simply place the out-of-the-box Eloqua code in GTM, it won’t work! But with this simple modification to the code, you can get Eloqua and GTM to work in harmony.

Here’s how to make your Eloqua script compatible with Google Tag Manager:

1. Obtain your base Eloqua tracking script. It should look something like this (Your code should have a numerical value in place of ‘xxxxxxxxx’).

<script type="text/javascript">
    var _elqQ = _elqQ || [];
    _elqQ.push(['elqSetSiteId', 'xxxxxxxxx']);
    _elqQ.push(['elqTrackPageView']);
    
    (function () {
        function async_load() {
            var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true;
            s.src = '//img.en25.com/i/elqCfg.min.js';
            var x = document.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x);
        }
        if (window.addEventListener) window.addEventListener('DOMContentLoaded', async_load, false);
        else if (window.attachEvent) window.attachEvent('onload', async_load);
    })();
</script>

2. Edit the code as follows: Replace the last two lines (if and else if statements, bolded above) with a single call to the async_load() function.

In the original script, these two lines determine when the Eloqua tracker fires. However, it is listening for an event (DOMContentLoaded or onload) which has potentially occurred before GTM fires the tag. Instead, we can remove this listener and use a DOM Ready firing rule (see Step 4), allowing GTM to control when the Eloqua tracker fires.

<script type="text/javascript">
    var _elqQ = _elqQ || [];
    _elqQ.push(['elqSetSiteId', 'XXXXXXXXX']);
    _elqQ.push(['elqTrackPageView']);
    
    (function () {
        function async_load() {
            var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true;
            s.src = '//img.en25.com/i/elqCfg.min.js';
            var x = document.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x);
        }        
        async_load(); //modification for GTM compatibility
    })();
</script>

3. Place the revised code in a new Custom HTML tag in your GTM container.

4. Set the tag to fire when the DOM is loaded by creating a new trigger. 

Create a new trigger and select the Trigger Type as Page View – DOM Ready.

5. Save your changes, create a new container version, and publish!

Good luck and let us know how it goes.

 

By |2018-07-25T10:42:37-04:00July 29th, 2014|13 Comments

13 Comments

  1. Micha February 19, 2015 at 8:48 am - Reply

    Hi Marc!
    Thanks for sharing this post!
    My question is whether from this moment Eloqua can listen & react on all events mapped via GTM. (meaning that not need to double-map events)
    Thanks!
    Micha

    • Marc Soares February 20, 2015 at 10:31 am - Reply

      Hi Micha,

      Thanks for your comment. The code included in this post is the base Eloqua tracking script. When fired, it will send the base pageview request to your instance of Eloqua. It will not automatically listen for any additional events or interactions on the page. However, you can take advantage of the auto-event listeners (or triggers) in GTM to send additional data to Eloqua upon specific user interactions, e.g. link clicks, downloads, form submissions, etc.

      You could create additional Custom HTML tags with the required Eloqua event tracking code, then fire these tags upon the appropriate rules/triggers. By leveraging GTM, you can avoid having to place code in the “onclick” event of links and buttons on the page, as long as the page elements are tagged with appropriate id or class attributes.

      For more information about event tracking with Eloqua, I recommend referring to the Eloqua documentation or contacting Eloqua support.

      Hope that helps!

  2. Greg August 5, 2015 at 4:45 pm - Reply

    I have issues where Eloqua website tracking is in two different pages of the same site. I can see my initial website visit from the email to page1,but if I click on the link to take me to page2, I never see that page2 visit. It has the same code in the same GTM container as page1. Any ideas?

    • Marc Soares August 6, 2015 at 12:43 pm - Reply

      Hi Greg,

      Thanks for sharing your question with us.

      Have you confirmed that the Eloqua tag is firing from GTM on page 2? If you have, then the problem is likely elsewhere in your website or Eloqua configuration.

      If you would like assistance troubleshooting this issue offline, please give us permission to contact you via email. A member of our Analytics team will then reach out and let you know our process and next steps.

      Thanks,
      Marc

  3. Phoenix May 10, 2016 at 4:29 am - Reply

    I am working for an e-commerce site which contains mixed http:// & https:// pages with 3rd cookie tracking. For Http:// pages tracking is working fine but for secure https:// webpages, I couldn’t track these pages.

    I am using script given on Eloqua site, same you are using above.
    I could n’t figure out the problem.

    • Marc Soares May 10, 2016 at 2:18 pm - Reply

      Hi there, I recommend contacting Eloqua support. You may need to modify the script in order to enable tracking on secure pages. Google Tag Manager works on both http and https pages, so you should still be able to deploy the modified script through GTM.

    • Andy October 13, 2016 at 10:08 am - Reply

      Hi – did you ever find a fix for this issue?

    • Andy December 8, 2016 at 10:44 am - Reply

      It’s possible this is because you need to install the certificate in Eloqua – something not included for free in our trim …

  4. laura December 6, 2016 at 5:09 pm - Reply

    Is this different now that it’s december 2016, I don’t see teh ability to set the trigger up you mentioned above for events as a trigger.

    • Justin S.J. Lee December 8, 2016 at 10:51 am - Reply

      Hi Laura, the GTM Interface has slightly changed since the post was made. The way to set up the trigger now would be to create a new trigger and choose DOM Ready under Trigger Type.

  5. Thomas January 25, 2017 at 9:25 am - Reply

    I have the same issues with https:, it doesn’t seem to work. I have asked our SFDC/Eloqua guy contact ELoqua.

  6. Ang Men September 3, 2018 at 6:51 am - Reply

    It worked! Thanks a lot for this…

Leave A Comment