简体   繁体   中英

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. 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

Any ideas why this is not working?

  1. Check if this work target="_blank" to the link to crosscheck the event.

  2. Also, verify if ur using analytics.js or gtag.js tracking code snippet.

  3. link it in double quote 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 ). Activate it and watch in the DevTools Console panel what happens when you click the target. It reports what was really sent to Google Analytics with the beacon. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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