AdWords Multiple Remarketing or Conversion Tags Not Working
 

AdWords Multiple Remarketing or Conversion Tags Not Working

May 17, 2017

Issue:

We recently ran into an interesting issue with AdWords remarketing tags and conversion pixels – trying to use more than a single tag snippet on the same page was resulting in only one tag fire, regardless of the number of tags added to the page or the order of the tags. This was even more perplexing than normal, since most forums or even official documentation pages say it is OK to have more than one tag on the same page and searching “adwords multiple remarketing tags not working” wasn’t turning up much help on Google.

It took some digging, but once I understood how AdWords tags work, the reason for my issue became clear – it is because we use a tag manager (Signal, similar to Google Tag Manager) to deploy our tracking pixels. The short version of why this break things is that AdWords tags are by default synchronous (and in a way that relies on that nature), but tag managers are asynchronous in how they work – imagine trying to put three trains on the same track and in the exact same location :O

A more in-depth explanation can be found at the bottom of the post, for those that are more interested in the code behind this.

Fix:

There are a few ways to fix this:

Easiest and best: Use your tag manager’s built in tag template instead of a custom template tag

When you use a custom tag (In GTM, this is a “Custom HTML” tag, in Signal a “Smart Custom Tag”) you are telling the tag manager to place the code you paste directly into the webpage, without any modifications. However, if you use their built in tag templates (for example, “AdWords Remarketing”) they actually have more advanced code behind the scenes that resolves issues – if you use multiple tags on the same page, it will ensure that they are loaded in a way that won’t break the tracking.

Easy: Make sure ALL AdWords tags go in the same custom template tag

If you insist on using a custom tag inside your tag manager, you can get around this issue by making sure that all of your adwords tag code snippets reside in the same custom tag. The multiple tag issue only occurs when they are separated into separate tags, since then each tag is loaded in an async nature. If they are in the same tag they will all get executed one after another (synchronous) although the entire tag is loaded async. This has the same effect as instead setting up a rule in your tag manager to sequence the tags so that they execute one after the other. However, this might not fix the issue in all tag managers.

Other: Don’t use a tag manager

If you place all your AdWords tags directly in the HTML code for the page instead of loading through a tag manager, this should also resolve the issue. This is why most forums will tell you that you can use multiple AdWords remarketing tags on the same page – because most people assume this is how you are implementing tags.

Moderately difficult: Use the async version of the tag

If you have found this page and suffer from the multiple tag issue, but are not using a tag manager, you might need this solution. This is likely the scenario if your website is designed as a single page application (SPA) or contains lots of async components.

Google offers an asynchronous version of the remarketing and conversion tags, which resolves this issue and allows you to use a custom code template. However, this requires modifying a little bit of Javascript, which is easy to mess up if you have zero experience with code. There are directions here on how to implement, or here is a sample snippet that shows firing a remarketing tag with an ID of “123456789”.

<script type="text/javascript" src="https://www.googleadservices.com/pagead/conversion_async.js" charset="utf-8"></script>
<script>
 asyncAdwordsConversion(123456789,null,null,true);
 
 function asyncAdwordsConversion(conversionID,OPT_conversionLabel,OPT_customParamsObject,OPT_remarketingOnly){
     conversionObject = {};
     conversionObject["google_conversion_id"] = parseInt(conversionID,10);
     if(typeof(OPT_customParamsObject)=="object" && OPT_conversionLabel != null){
         conversionObject["google_custom_params"] = OPT_customParamsObject;
     }
     OPT_remarketingOnly = (OPT_remarketingOnly||false);
         conversionObject["google_remarketing_only"] = OPT_remarketingOnly;
     if (typeof(OPT_conversionLabel)!= "undefined" && OPT_conversionLabel != null){
         conversionObject["google_conversion_label"] = OPT_conversionLabel.toString();
     }
     window.google_trackConversion(conversionObject);
 }
</script>

 


More in-depth explanation of WHY this issue exists:

The crux of this issue is the way in how the standard version of the Adwords remarketing or conversion pixel works. Lets break it down by using the sample code from AdWords:

<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 123456789;
var google_custom_params = window.google_tag_params;
var google_remarketing_only = true;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"></script>
<noscript>
  <div style="display:inline;">
        <img height="1" width="1" style="border-style:none;" alt="" 
        src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/123456789/?value=0&amp;guid=ON&amp;script=0"/>
  </div>
</noscript>

The first <script> tag declares and assigns a value to three globally scoped javascript variables. The second script tag loads an external javascript code file and executes it -> conversion.js checks the values of the three global variables and uses the values to fire a corresponding pixel. Note that both script tags do not use the “async” attribute, so by default they are loaded synchronously.

Scenario: Multiple tags directly in HTML source

If there are multiple tags on the same page, but they are placed directly in the HTML source code, there is no issue. Here is an example:

<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 123456789;
var google_custom_params = window.google_tag_params;
var google_remarketing_only = true;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"></script>
<noscript>
  <div style="display:inline;">
        <img height="1" width="1" style="border-style:none;" alt="" 
        src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/123456789/?value=0&amp;guid=ON&amp;script=0"/>
  </div>
</noscript>
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 999999999;
var google_custom_params = window.google_tag_params;
var google_remarketing_only = true;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"></script>
<noscript>
  <div style="display:inline;">
        <img height="1" width="1" style="border-style:none;" alt="" 
        src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/123456789/?value=0&amp;guid=ON&amp;script=0"/>
  </div>
</noscript>

In the above code, the first <script> tag sets the conversion ID equal to “123456789”, then conversion.js loads, reads the global var, and fires a pixel with “123456789”. Then the second block starts executing and the 3rd <script> overwrites the globally scoped “google_conversion_id” and sets it equal to “999999999”. Conversion.js loads again, reads the global var, and fires a pixel with an id of “999999999”.

Scenario: When things go wrong – async loading or messed up globals

If the above two code snippets were placed into separate async snippets (either through a tag manager or some other method) you end up creating a race condition like scenario. Why? The code right after “/* <![CDATA[ */” that sets the global variables executes immediately and takes almost no time to execute, but the conversion.js code takes longer and its execution time is unknown, since it is loaded from an external source. So if you have two custom HTML tags in your tag manager, each with a separate remarketing tag, here is what happens:

  1. BOTH tags start executing at the same time. Since the “CDATA” portion takes almost no time to execute, one of the two tags will execute it’s CDATA portion first and set the globals, then hit the conversion.js tag and wait for it to load, while milliseconds later the other tag will overwrite the globals that were just set and then also hit the conversion.js part and wait.
  2. Conversion.js now loads twice, once from each tag, but since it is reading globally scoped variables, it only retrieves the values set by the tag that executed its CDATA portion last.
  3. Each conversion.js instance fires a pixel/tracking tag with the last values held in the global variables.

Having trouble getting the results you need with AdWords? Check out how we can help you up your paid search game – click here!

Leave a Reply

Your email address will not be published. Required fields are marked *

More Services