Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a Custom HTML tag in Google Webmaster tools that is actually very simple. It consists of the following code (a GTM Macro):

{{html generator}}

This tag is only fired on the Thank-you page on my website. This firing rule works fine, as I'm using it for a couple of other tags.

The Custom Javascript {{html generator}} macro is more complex. The macro generates one or two image pixels in HTML. Due to the complexity of the image pixels, I cannot use the Custom Image tag. :

<img src="url1/?query1" width="1" height="1" /><img src="url2/?query2" width="1" height="1" />

Via console.log I have verified that the macro Javascript function generates the correct string.

Why is the HTML not executed? I don't believe it is a caching issue as the query parameters always have a different outcome. I believe it is a timing issue.

Update: I think I found a solution, but still it is unclear to me why it did not work in the first place.

Solution:

<script type='text/javascript'>
  var tag = decodeURI({{A4Y segmented tag}});
  document.write(tag);
</script>

This solution requires you to check the box: []Support document.write

share|improve this question
    
"...in Google Webmaster Tools" - Do you mean "Google Analytics"? Are the elements present in the resulting page? ie. Are they in the DOM? –  w3d May 16 at 22:44
    
I do mean Google Tag Manager. The tag presented above has nothing to do with Google Analytics. –  Martin Voorzanger May 17 at 6:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.