简体   繁体   English

Google Analytics 事件跟踪不会跟踪两次或更多次

[英]Google Analytics Event Tracking doesn't track twice or more

I am trying to track an event via Google Analytics but unfortunately it only works for the first time I click the element.我正在尝试通过 Google Analytics 跟踪事件,但不幸的是,它仅在我第一次单击该元素时有效。 When I change the browser it only works the first time again.当我更改浏览器时,它只能再次运行。 I use this simple code to track:我使用这个简单的代码来跟踪:

ga('send', 'event', 'footer', category , label, 1);

category and label are JS variables categorylabel是 JS 变量

Any ideas why this is not working?任何想法为什么这不起作用?

  1. Check if this work target="_blank" to the link to crosscheck the event.检查此工作 target="_blank" 是否指向链接以交叉检查事件。

  2. Also, verify if ur using analytics.js or gtag.js tracking code snippet.此外,请验证您是否使用了 analytics.js 或 gtag.js 跟踪代码片段。

  3. link it in double quote href="http://mywebpage.com"在双引号 href="http://mywebpage.com" 中链接它

It would help you if you install Chrome extension GA Debugger ( https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna?hl=en ).如果您安装 Chrome 扩展 GA Debugger ( https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna?hl=en ),它会对您有所帮助。 Activate it and watch in the DevTools Console panel what happens when you click the target.激活它并在 DevTools Console 面板中观察单击目标时会发生什么。 It reports what was really sent to Google Analytics with the beacon.它通过信标报告真正发送到 Google Analytics 的内容。 For example I have:例如我有:

ga( "send", "event", "Videos", "play", "Fall Campaign", 1 );

which is called when user click the link.当用户单击链接时调用。 Every time I click the link I get in the console a new payload like:每次单击链接时,我都会在控制台中获得一个新的有效负载,例如:

Running command: ga("send", "event", "Videos", "play", "Fall Campaign", 1)
Sent beacon:
v=1&_v=j79d&aip=1&a=1635498924&t=event..

I keep also open https://analytics.google.com/analytics/web/ on Realtime/Events/Events (Last 30 min) and observer every time a new event registered.每次注册新事件时,我都会在 Realtime/Events/Events(最后 30 分钟)和观察者上打开https://analytics.google.com/analytics/web/

PS Just to avoid the case where some events not being really delivered to Google Analytics, let's say after code update, I have automated tests set like described here https://docs.puppetry.app/testing-techniques/testing-google-analytics-tracking-code PS 只是为了避免某些事件没有真正传递给 Google Analytics 的情况,假设在代码更新后,我设置了自动化测试集,如下所述https://docs.puppetry.app/testing-techniques/testing-google-analytics -跟踪代码

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

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