如何阻止Google Tagmanager更改javascript值?

时间:2018-02-21 16:24:34

标签: javascript decode equals encode google-tag-manager

这是Google Tagmanager中的自定义Html标记:

<script>
 _dAutomationGtmAddTimer("mysite.com", "bh2Ry58My0NWFw==", {"cmp1": 
 visitorContactInfo[0], "cmp2": visitorContactInfo[1], "cart_data":[{"amount":orderFormProducts[quantity],"id":orderFormProducts[sku],"image":"","link":"URL produto","name":orderFormProducts[name],"description":"","unitary_value":orderFormProducts[sellingPrice]}]})
</script>

当Tagmanger注入DOM时,第二个参数"bh2Ry58My0NWFw=="更改为"bh2Ry58My0NWFw\x3d\x3d",将==替换为\x3d\x3d

请知道如何防止此值发生变化?

1 个答案:

答案 0 :(得分:0)

尝试这种方法:

首先,创建一个常量变量:

  • 变量名称:API密钥
  • 变量值:bh2Ry58My0NWFw==

然后,将自定义HTML标记修改为

<script>
 _dAutomationGtmAddTimer("mysite.com", "{{API key}}", {"cmp1": 
 visitorContactInfo[0], "cmp2": visitorContactInfo[1], "cart_data":[{"amount":orderFormProducts[quantity],"id":orderFormProducts[sku],"image":"","link":"URL produto","name":orderFormProducts[name],"description":"","unitary_value":orderFormProducts[sellingPrice]}]})
</script>