Google Tag Manager

倖福魔咒の 提交于 2019-12-11 08:04:46

问题


I inserted a Google Tag Manager code snippet below the body tag but my website will only display a blank white page. When I remove it, the page displays correctly.

<!-- Google Tag Manager -->
<noscript>
<iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXXXX" height="0" width="0" style="display:none;visibility:hidden">
</iframe>
</ noscript> 
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '//www.googletagmanager.com/gtm.js?id='+i +dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-XXXXXX');
</script> 
<!-- End Google Tag Manager -->

回答1:


This could be security rules on your firewall. Many web application firewalls will block 0- width frames to block potential code injection vectors.

Try removing the 'style="display:none;visibility:hidden"' attribute and giving your iframe a height and a width of 100.

If that works, then probably some security system somewhere is blocking the iframe, you can normally fix this by moving the iframe styles out to an external stylesheet like this:

<noscript>
  <iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXXXX" class ="gtmIframe">
  </iframe>
</ noscript>...

and in your stylesheet:

.gtmIframe {
  width:0;
  height:0;
  display:none;
  visibility:hidden;
}



回答2:


What tags are installed in your GTM container? Specifically, are you using any "Custom HTML" tags? If so, I've seen the document.write() method do this to pages before. So make sure you check the "Support document.write" box underneath the code block in your tag.

Thanks




回答3:


Just spend half a day on it. If you have the same problem has me it is because you are using Smarty and he doesn't recognise it as Js or something like that. I had to use {literal} ... {/literal} tags. Hope this could help someone.




回答4:


Try to replace

'&l' 

with

'&amp;l'

Let me know is it works...




回答5:


Without many details, it is a little hard to figure this out.

  • Is the main code in the head tag?

    <!-- Google Tag Manager --> <scrIpt>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-XXXXXX');</script> <!-- End Google Tag Manager -->

This script should be as high in the head tag as possible.

If this script is present and there is nothing else wrong. Then there would be code around this that is breaking, or code inside of it. Are there tags in GTM setup to do something that may cause the page to break? Is it only this page? Can you create a new page, fresh HTML, nothing else on it except a paragraph and headline, add the GTM code? Once you do this, and assuming the H1 and p are visible, then add the rest of your page, piece by piece, until the page breaks. You will then know what is breaking GTM.

That is the best advice I can offer without taking a look myself.

-Cheers




回答6:


I found the solution of these.

They change something in the URL

In the blank frame https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"

and the Iframe who really works is with these

https://www.googletagmanager.com/**gtm.js?id=**GTM-XXXXXXX

Let me know if they work for you



来源:https://stackoverflow.com/questions/23332024/google-tag-manager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!