简体   繁体   English

Google标记管理器在脚本src中添加just和instrad

[英]Google tag manager adding & instrad of just & into script src

I am using Google tag manager to add the analytics script to my site, it is working correctly on most pages however seems to be inserting the scrip tag incorrectly on others. 我正在使用Google标记管理器将分析脚本添加到我的网站,它在大多数页面上均正常运行,但是似乎在其他页面上未正确插入脚本代码。

It is using & 它正在使用& instead of just & in the analytics script tag src. 而不是仅仅&在分析脚本标签SRC。

Example: 例:

The tag created looks like this: 创建的标签如下所示:

<script async="" src="//www.googletagmanager.com/gtm.js?id=GTM-PZK7CW&amp;l=GoogleDataLayer">

not

<script async="" src="//www.googletagmanager.com/gtm.js?id=GTM-PZK7CW&l=GoogleDataLayer">

See an example at: https://www.jumbolotto.de/marketing/gratis . 请参阅以下示例: https : //www.jumbolotto.de/marketing/gratis It is loading correctly on the home page with the same google tag script. 它使用相同的Google标记脚本正确加载到首页上。

The Google tag script looks like this Google标记脚本如下所示

<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-PZK7CW" 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'?'&amp;l='+l:'';j.async=true;j.src=
        '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
    })(window,document,'script','GoogleDataLayer','GTM-PZK7CW');
</script>
<!-- End Google Tag Manager -->

If you look at your Google tag manager script, you'll see that the ampersand is encoded. 如果您查看Google跟踪代码管理器脚本,则会发现&字符已编码。

dl=l!='dataLayer'?'&amp;l='+l:'';

You should check to make sure that the correct code is inserted into your page. 您应该检查以确保将正确的代码插入到页面中。 Something in the process of copying the code from GTM to rendering the code on the page has encoded the ampersand. 从GTM复制代码以在页面上呈现代码的过程中,某些内容已对“&”号进行了编码。

Also, you should insert the GTM code immediately after the <body> tag and not at the bottom of the page just before the </body> tag. 另外,您应该在<body>标记之后而不是在页面底部</body>标记之前插入GTM代码。

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

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