Google Analytics Tracking works in Editor, but not Live Builds

My PlayCanvas game uses Google Analytics Events to track simple stats like initialize game, start game, game complete.

When I launch the game from the PlayCanvas Editor, I can see them show up under Real Time -> Events in my Google Analytics Dashboard. When I publish a build and play it however, no events show up, both when I click the build link directly or when I start the game on the site it’s embedded in.

  • The Google Analytics tag is set up in a separate analytics.js script, and that script is executed at the top of the script order, as described here.
  • Console logs placed before and after the event call are always logged
  • I first made and published this game a year ago and the only thing I’ve changed about the analytics is adjusting the tracking code so it goes to a different site than it used to. That first version of the game had the events working correctly and I’m using the same code for the analytics.

Anyone have ideas/pointers for why the tracking might work when launching from the editor but not when launching a published build?

Thanks in advance

EDIT/SOLUTION:

My adblocker was at fault :woman_facepalming:
Did not realize adblockers blocked Analytics as well as ads. I had disabled the adblocker on the editor site, but it was enabled on the live site. The Google Analytics Debugger Extension helped me see the problem and showed a “cookie write failed” message that I was able to fix by setting the flag as described here: https://github.com/react-ga/react-ga/issues/457

Do you see any errors, logs etc in the browser dev console when you try your published build?

Edit: You may want to try this tool too: https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna

(Found on this article with trouble shooting steps) https://www.analyticsmania.com/post/google-analytics-real-time-reports-not-working/

Hi, thanks for your response. No, I don’t get any error logs in the dev console in either the editor launch or the published build. In both cases, my logs right before and after the ga event code are shown, so that part of the code is reached and executed.

I tried adding the GA debugger tool: the debug tool runs when launching from editor, but gets blocked when playing a live build. Then I get the following error message:

analytics.js:4 GET https://www.google-analytics.com/analytics_debug.js net::ERR_BLOCKED_BY_CLIENT

Note: this is only for the debugger tool, but since it works in the editor but not in the live build, it may be the same issue. Any idea how to progress from here? Thank you!

Do you have any browser extensions that could be blocking events etc? Ed ghostery, Adblock etc?

1 Like

Yes, I just realized my Adblocker was part of the problem. After disabling it, I was able to run the debugger tool. I got an error message saying “cookie write failed” so I’m trying the solution described here.