简体   繁体   English

GTM iFrame问题

[英]GTM iFrame Issue

I am using GTM in our site as below. 我在以下网站上使用GTM But in Network panel of Chrome I can see that request is got canceled. 但是在Chrome的“网络”面板中,我可以看到该请求已被取消。 I checked the javascript code where it failed but it is only form submit code. 我检查了失败的javascript代码,但这只是表单提交代码。 I believe this happened because of iFrame is not supported by Google Chrome. 我相信发生这种情况是因为Google Chrome不支持iFrame Is there another way of using GTM without iFrame . 还有没有iFrame使用GTM的另一种方法。

<!-- Google Tag Manager -->
<noscript>
<iframe src="//www.googletagmanager.com/ns.html?id=GTM-TW7XQX" 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-TW7XQX');
</script>
<!-- End Google Tag Manager -->

在此处输入图片说明

Updtae: 更新:

Found this is not happening due to iFrame but something else. 发现这并不是由于iFrame发生,而是其他原因。 iFram will only be triggered if javascript is disabled. 仅当禁用javascript时才会触发iFram。 In this case configured GTM tags are the root cause. 在这种情况下,已配置的GTM标签是根本原因。

If you look at the code you'll see that the iframe is in noscript tags - it will only ever be called for clients who do not have javascript enabled. 如果您看一下代码,就会看到iframe位于noscript标记中-只会为未启用javascript的客户端调用。 GTM will work fine without it, and most people do not even configure GTM for clients without JS (personally I just drop the noscript part and move the GTM code to the page head). 没有它,GTM就能很好地工作,而且大多数人甚至都不会为没有JS的客户端配置GTM(我个人只是放下noscript部分并将GTM代码移到页面头)。

However Google Chrome supports iframes just fine, and the tag that is aborted seems to be a javascript tag in any case. 但是Google Chrome浏览器仅支持iframe,在任何情况下被中止的代码似乎都是javascript代码。 So this problem cannot possibly related to the iframe (which isn't even called as long as the client runs JS). 因此,此问题可能与iframe无关(只要客户端运行JS,iframe甚至不会调用)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM