Google Tag Manager在生产环境中破坏了src属性。

huangapple go评论59阅读模式
英文:

Google Tag Manager is breaking src attribute in production

问题

我有一个跟踪的Iframe,通过自定义HTML标签部署,并在窗口加载事件上触发。

src属性使用多个自定义JS变量来填充某些可用参数。

然而,在生产环境中,src属性充满了在预览模式中未显示的错误。变量本身没有问题,因为它们都经过了广泛的单元测试。

以下是(1)在GTM中显示的iFrame的src属性的标签配置,(2)在预览/调试模式下生成的HTML,以及(3)实际在生产中生成的HTML:

  1. src="//servedby.flashtalking.com/container/14745;109435;11282;iframe/?ftXRef={{TransID Availability Test - Onetag}}&ftXValue={{Revenue Availability Test - Onetag}}&ftXType=FTXTYPE_VALUE&ftXName=FTXNAME_VALUE&ftXNumItems=FTXNUMITEMS_VALUE&ftXCurrency=FTXCURRENCY_VALUE&U1=U1_VALUE{{dataLayer Stations Output - Onetag}}{{Journey Date Output - Onetag}}{{Journey Ticket Type Output - Onetag}}&U8=U8_VALUE&U9=U9_VALUE&U10=U10_VALUE&U11=U11_VALUE&U12=U12_VALUE&U13=U13_VALUE&U14=U14_VALUE&U15=U15_VALUE&U16=U16_VALUE&U17=U17_VALUE&U18=U18_VALUE&U19=U19_VALUE&U20=U20_VALUE&ft_referrer={{Encoded Page URL}}&ns={{Referrer}}&cb={{Random Number}}"

  2. https://servedby.flashtalking.com/container/14745;109435;11282;iframe/?ftXRef=2526968585&ftXValue=1.2***&ftXType=FTXTYPE_VALUE&ftXName=FTXNAME_VALUE&ftXNumItems=FTXNUMITEMS_VALUE&ftXCurrency=FTXCURRENCY_VALUE***&U1=U1_VALUE%26U2%3DU2_VALUE%26U3%3DU3_VALUE%26U4%3D28%2F12%2F19%26U5%3D%26U6%3DSDS%26U7%3DU7_VALUE&U8=U8_VALUE&U9=U9_VALUE&U10=U10_VALUE&U11=U11_VALUE&U12=U12_VALUE&U13=U13_VALUE&U14=U14_VALUE&U15=U15_VALUE&U16=U16_VALUE&U17=U17_VALUE&U18=U18_VALUE&U19=U19_VALUE&U20=U20_VALUE&ft_referrer=https%253A%252F%252Fwww.domain.co.uk%252Fbuytickets%252Fpaymentconfirmation.aspx&ns=https%3A%2F%2Fwww.domain.co.uk%2Fbuytickets%2Fpaymentconfirmation.aspx&cb=126603136

  3. https://servedby.flashtalking.com/container/438;87804;9034;iframe/?ftXRef=2526968585&ftXValue=1.2&U1=paymentconfirmation&U3=1&U4=01000&U7=28/12/19&U9=BIRMINGHAM%20NEW%20STREET&U10=BIRMINGHAM%20SNOW%20HILL&ft_referrer=https%3A//www.domain.co.uk/buytickets/paymentconfirmation.aspx&ns=https%3A//www.domain.co.uk/buytickets/paymentconfirmation.aspx&cb=473400.6608119874

如您所见,在生产中,(2)中粗体/斜体部分被完全删除,尽管这些参数未配置为由任何变量填充或修改。同样,参数U9和U10似乎是从无中生成的 - 它们没有设置为由任何变量填充。

那些配置为由自定义变量填充的参数没有正常工作 - 在生产中显示的值要么不存在,要么与在调试/预览中或在单元测试中给出的结果不匹配,这表明问题出在GTM本身。

英文:

I have a tracking Iframe that is deployed through a custom HTML tag and triggered on the window loaded event.

The src attribute takes several custom JS variables to populate certain parameters where available.

However, in production the src attribute is full of errors that aren't showing up in preview mode. There are no issues with the variables themselves, as they have all been unit tested extensively.

Below are (1) the tag config for the iFrame's src attribute as shown within GTM, (2) the html produced in preview/debug mode, and (3) the html that's actually being produced in production:

  1. src="//servedby.flashtalking.com/container/14745;109435;11282;iframe/?ftXRef={{TransID Availability Test - Onetag}}&ftXValue={{Revenue Availability Test - Onetag}}&ftXType=FTXTYPE_VALUE&ftXName=FTXNAME_VALUE&ftXNumItems=FTXNUMITEMS_VALUE&ftXCurrency=FTXCURRENCY_VALUE&U1=U1_VALUE{{dataLayer Stations Output - Onetag}}{{Journey Date Output - Onetag}}{{Journey Ticket Type Output - Onetag}}&U8=U8_VALUE&U9=U9_VALUE&U10=U10_VALUE&U11=U11_VALUE&U12=U12_VALUE&U13=U13_VALUE&U14=U14_VALUE&U15=U15_VALUE&U16=U16_VALUE&U17=U17_VALUE&U18=U18_VALUE&U19=U19_VALUE&U20=U20_VALUE&ft_referrer={{Encoded Page URL}}&ns={{Referrer}}&cb={{Random Number}}"
  2. https://servedby.flashtalking.com/container/14745;109435;11282;iframe/?ftXRef=2526968585&ftXValue=1.2***&ftXType=FTXTYPE_VALUE&ftXName=FTXNAME_VALUE&ftXNumItems=FTXNUMITEMS_VALUE&ftXCurrency=FTXCURRENCY_VALUE***&U1=U1_VALUE%26U2%3DU2_VALUE%26U3%3DU3_VALUE%26U4%3D28%2F12%2F19%26U5%3D%26U6%3DSDS%26U7%3DU7_VALUE&U8=U8_VALUE&U9=U9_VALUE&U10=U10_VALUE&U11=U11_VALUE&U12=U12_VALUE&U13=U13_VALUE&U14=U14_VALUE&U15=U15_VALUE&U16=U16_VALUE&U17=U17_VALUE&U18=U18_VALUE&U19=U19_VALUE&U20=U20_VALUE&ft_referrer=https%253A%252F%252Fwww.domain.co.uk%252Fbuytickets%252Fpaymentconfirmation.aspx&ns=https%3A%2F%2Fwww.domain.co.uk%2Fbuytickets%2Fpaymentconfirmation.aspx&cb=126603136
  3. https://servedby.flashtalking.com/container/438;87804;9034;iframe/?ftXRef=2526968585&ftXValue=1.2&U1=paymentconfirmation&U3=1&U4=01000&U7=28/12/19&U9=BIRMINGHAM%20NEW%20STREET&U10=BIRMINGHAM%20SNOW%20HILL&ft_referrer=https%3A//www.domain.co.uk/buytickets/paymentconfirmation.aspx&ns=https%3A//www.domain.co.uk/buytickets/paymentconfirmation.aspx&cb=473400.6608119874

​​As you can see, the section in (2) in bold/italics is being removed entirely in production, despite the fact that these parameters aren't configured to be populated or modified by any variables. Similarly, parameters U9 and U10 are being populated seemingly from nothing - they aren't set to be populated by any variables.

Those parameters that are configured to be populated by custom variables aren't working properly - the values shown in production are either absent or else don't match the results given either in debug/preview or in unit testing, which suggests the problem is with GTM itself.

答案1

得分: 2

你确定这两个标签是相同的吗?看起来顶部标签开始于

>/container/14745;109435;11282

而底部标签开始于

>/container/438;87804;9034

对我来说,这两个标签看起来完全不同,我不相信它们是相同的。GTM 可能会做很多事情,但它不会随机更改你的代码!我从未见过它删除变量、添加变量或更改字符串,它没有这个能力。自定义 HTML 标签会按照原样写入 GTM.js 文件,只有变量会被宏替换。

如果你最近更新了标签,那么你看不到变化的其他原因可能是:

  1. 你正在查看 GTM 的缓存版本,在这种情况下,请清空缓存,刷新页面,问题应该解决。
  2. 你正在工作并预览尚未发布的更改,因此不会在实时站点上显示;如果你发布更改,问题应该得以解决。

如果以上两种方法都不起作用,那么如果你能分享站点链接,我可以进行调查!

英文:

Are you sure that these are the same tag? Looking at the top tag it starts

>/container/14745;109435;11282

and the bottom tag starts
>/container/438;87804;9034

To me, the tags seem so completely different that I don't believe they're the same. GTM may do many things, but it doesn't randomly change your code! I've never seen it remove variables, or add them in, or change strings, it wouldn't have the ability to. Custom HTML tags are literally written 'as is' into the GTM.js file, with the exception of variables being replaced with macros.

If you've recently updated the tag then other reasons you're not seeing the changes may be:

  1. You're looking at a cached version of GTM, in which case empty your cache, refresh the page and that should sort it.
  2. You're working in and previewing changes that haven't been published, so won't show on the live site; if you publish the changes that should work.

If neither of those work then it would be good if you could share a link to the site so I can investigate!

huangapple
  • 本文由 发表于 2020年1月3日 19:11:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/59577555.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定