简体   繁体   English

Google跟踪代码管理器dataLayer推送未存储对象

[英]Google Tag manager dataLayer push not storing object

I've read through several SO posts and the docs and api . 我已经阅读了几篇SO帖子以及docsapi My understanding is that the dataLayer global object should behave Array-like and increase in size when you .push() an event object into it. 我的理解是,当您将事件对象.push()放入其中时, dataLayer全局对象的行为应类似于Array并增加大小。 According to the screenshot here . 根据这里的截图。

My dataLayer object does not grow like this. 我的dataLayer对象不会像这样增长。 It exists on the window and I can run 它存在于窗口中,我可以运行

dataLayer.push({'event': 'trackEvent'});

without error, except that it does not increase the size of dataLayer. 没有错误,只是它不会增加dataLayer的大小。

Other than the array growing and how else can I tell if .push() is working or not? 除了数组增长以外,我还能如何判断.push()是否正常工作?

Should the browser perform an xhr request when events are detected? 当检测到事件时,浏览器是否应该执行xhr请求?

Does the GTM script perform client-side logic based off of GTM settings (tags/triggers) before sending them to google? GTM脚本在发送给Google之前,是否会根据GTM设置(标签/触发器)执行客户端逻辑? ie, are the events not pushing because they don't pass validation. 也就是说,事件没有推送,因为它们没有通过验证。

Does it matter if I'm testing this on localhost? 如果要在localhost上进行测试,这有关系吗?

How do I fix this? 我该如何解决?

Google Tag Assistant扩展 在此处输入图片说明

The datalayer is an array, so yes, it should behave like an array. 数据层是一个数组,所以是的,它的行为应类似于数组。 The individual items are objects. 单个项目是对象。

It should not perform xhr requests, since GTM is bundled and downloaded in toto to your page, so xhr would not be needed. 它不应该执行xhr请求,因为GTM已捆绑并下载到您的页面中,所以不需要xhr。

GTM events are by themselves never send to Google (they are only used to trigger tags, which then might send data to Google. They not automatically map to Google Analytics events). GTM事件本身永远不会发送给Google(它们仅用于触发代码,然后标记可能会将数据发送给Google。它们不会自动映射到Google Analytics(分析)事件)。 They are not validated, GTM just amends the push method to see if the arguments contain the key "event" (at which point the internal state of the GTM script is updated with the new values). 它们未经验证,GTM只是修改push方法,以查看参数是否包含键“事件”(此时,GTM脚本的内部状态将使用新值进行更新)。

It seems that something happens to your datalayer after GTM is loaded (you have the start event, but no gtm.dom or gtm.load) so you might want to check if datalayer is re-declared after the GTM snippet. 加载GTM后,数据层似乎发生了一些变化(您有start事件,但是没有gtm.dom或gtm.load),因此您可能要检查在GTM代码段后是否重新声明了数据层。 But to actually debug the problem it would help if we could see how you embed GTM and set up your datalayer (if there is any chance we could have a glance at your page, or an example page that shows the same problem, that would be very helpful). 但是要实际调试问题,如果我们能够看到您如何嵌入GTM并设置数据层,这将有所帮助(如果有可能,我们可以浏览一下您的页面或显示相同问题的示例页面,那将是很有帮助)。

My colleague was able to load the preview mode and verify the event pushing into dataLayer. 我的同事能够加载预览模式并验证将事件推送到dataLayer中。 Apparently the duckduckgo extension was preventing the loading of the preview mode task bar. 显然,duckduckgo扩展程序阻止了预览模式任务栏的加载。

I'll be opening this as a bug with the DDG team. 我将与DDG团队一起将其作为Bug打开。

For future searchers, you should be able to pull up gtm preview mode pretty easily. 对于将来的搜索者,您应该能够轻松启动gtm预览模式。 You would see network events like in the screenshot. 您会在屏幕截图中看到网络事件。 在此处输入图片说明

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

相关问题 Google标记管理器-是否可以通过GTM标记插入dataLayer? - Google tag manager - is it possible to push into dataLayer via GTM tag? 尽管执行了DataLayer推送,但Google跟踪代码管理器代码未触发 - Google Tag Manager tag not triggered despite DataLayer push being executed 解析eCommerse数据以推送到Google Tag Manager的dataLayer - Parsing eCommerse data to push into dataLayer for Google Tag Manager Google跟踪代码管理器是否“订阅” dataLayer.push? 如果是,怎么办? - Does Google Tag Manager “subscribe” to dataLayer.push? If yes, how? Firefox 增强的隐私保护正在阻止数据层推送到谷歌标签管理器 - Firefox Enhanced Privacy Protection is blocking Datalayer push to Google Tag Manager 如何将表单提交推送到谷歌标签管理器 (gtm) 中的数据层 - How to push a form submission to the dataLayer in google tag manager (gtm) Google跟踪代码管理器dataLayer持久性 - Google Tag Manager dataLayer persistency 跟踪代码管理器无法识别Google跟踪代码管理器dataLayer - Google Tag Manager dataLayer unrecognized by Tag Manager 填充 Google 标签管理器数据层的问题 - Problems Populating the Google Tag Manager datalayer Google跟踪代码管理器和dataLayer中的自定义Javascript变量 - Custom Javascript variable in Google Tag Manager and dataLayer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM