Expand my Community achievements bar.

SOLVED

Google Remarketing code not working in DTM

Avatar

Level 2

Hi,

 

I have implemented the following third party code into page load rules in DTM:

<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 971225648;
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/971225648/?value=0&amp;guid=ON&amp;script=0"/>
</div>
</noscript>

It only recognises it as Non-Sequential HTML, however.

When debugging the site, it show's up as red and an unhappy face so I'm assuming it's not working. (sorry I'm new to this!)

 

Any advise would be hugely appreciated.

 

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Al,

It should be very do-able.

it is notable that they have different code is you want to deploy it async

instead of "//www.googleadservices.com/pagead/conversion.js" you have to call "//www.googleadservices.com/pagead/conversion_async.js"

and then do some magic to make sure that file loads before you reference it

Please add the following code "Non Sequential JS" Third Party Tag

var dcJS = document.createElement('SCRIPT'); var done = false; dcJS.setAttribute('src', '//www.googleadservices.com/pagead/conversion_async.js'); dcJS.setAttribute('type','text/javascript'); document.body.appendChild(dcJS); dcJS.onload = dcJS.onreadystatechange = function () { if(!done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) { done = true; callback(); // Handle memory leak in IE dcJS.onload = dcJS.onreadystatechange = null; document.body.removeChild(dcJS); } }; function callback(){ if(done){ /* <![CDATA[ */ window.google_trackConversion({ google_conversion_id : XXXXXXX, google_custom_params : window.google_tag_params, google_remarketing_only : true }); //]]> } }

Thanks & Regards

Parit Mittal

View solution in original post

9 Replies

Avatar

Level 8

Hi Nickola,

Could you paste screenshots of the error on your console and your page load rule setup?

Regards

Rahul

Avatar

Level 2

Here's the screenshot of the error, it suggests there's a missing <script> tag.

 

Displaying image.png

 

 

Inline images 2

 

 

And this is a screen shot of the rule I've set up in DTM:

 

Displaying image.png

and this is the error i see when trying to change it to java-script:

Displaying image.png

 

Thanks

Nicola

Avatar

Level 8

Hi Nicola,

I can't see the images. Could you try uploading them again please?

Regards

Rahul

Avatar

Level 2

I've popped them into a google doc (https://docs.google.com/document/d/17B7k8KfadDGSUDHoC1aaaZzems9uUu7NKynjr2kaKYA/edit?usp=sharing)

Can you see them on there?

 

Thanks so much for having a look- really appreciate :)

 

Nicola

Avatar

Level 8

Thanks! I can see them now. Let me look at it and get back to you.

Just as a first point of check, shouldn't you be commenting out the text on line 13?

just put '/*' before the line and '*/' after it and check if that works.

Kindly revert if the problem persists (I'll look to see if I can find anything else).

Regards

Rahul

Avatar

Level 2

Hi Nicola and Rahsing, I'm having the same issue, did you ever solve the problem?

Thanks,

Ron

Avatar

Level 2

I am also having the same issue. Did anyone get the Google Remarketing tag to play nicely with Adobe DTM? Or is the conclusion that Google Remarketing tag should be implemented separately outside of DTM?

Thanks,

Al

Avatar

Correct answer by
Level 10

Hi Al,

It should be very do-able.

it is notable that they have different code is you want to deploy it async

instead of "//www.googleadservices.com/pagead/conversion.js" you have to call "//www.googleadservices.com/pagead/conversion_async.js"

and then do some magic to make sure that file loads before you reference it

Please add the following code "Non Sequential JS" Third Party Tag

var dcJS = document.createElement('SCRIPT'); var done = false; dcJS.setAttribute('src', '//www.googleadservices.com/pagead/conversion_async.js'); dcJS.setAttribute('type','text/javascript'); document.body.appendChild(dcJS); dcJS.onload = dcJS.onreadystatechange = function () { if(!done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) { done = true; callback(); // Handle memory leak in IE dcJS.onload = dcJS.onreadystatechange = null; document.body.removeChild(dcJS); } }; function callback(){ if(done){ /* <![CDATA[ */ window.google_trackConversion({ google_conversion_id : XXXXXXX, google_custom_params : window.google_tag_params, google_remarketing_only : true }); //]]> } }

Thanks & Regards

Parit Mittal

Avatar

Level 2

Thanks Parit. This solutions seems to be working well.