在字符串常量中停止GTM编码'=='

时间:2019-08-27 16:58:48

标签: google-tag-manager

当我将此示例GTM标记注入网站时,src字符串中的'=='编码为\ x3d \ x3d,但无法解析。有没有办法停止编码?

GTM标签:

<script type="text/javascript"> !function(o,t){var src="https://test@testsite.com/test/1MmE5ZDA4ZGExODZkOTQifQ==/assets/demo.js"; ... </script>

在页面上

<script type="text/javascript"> !function(o,t){var src="https://test@testsite.com/test/1MmE5ZDA4ZGExODZkOTQifQ\x3d\x3d/assets/demo.js"; ... </script>

1 个答案:

答案 0 :(得分:0)

我在尝试将src插入iframe时遇到类似的问题。我在查询字符串中填充了包含“ =”的GTM变量,但它们将被编码为%3D。

我的解决方案是使用Javascript在页面上注入HTML标记。

旧方式(HTML)

<iframe height="1" width="1" frameborder="0" scrolling="no" src="https://www.something.com/?containerTagId={{containerID}}"></iframe>

NEW WAY(JAVASCRIPT)

<script>
var script = document.createElement('iframe');
script.height="1";
script.width="1";
script.frameborder="0";
script.scrolling="no";
script.name="conversion";
script.src = 'https://www.something.com/?containerTagId={{containerID}}';
document.body.appendChild(script);
</script>