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
My adblocker was at fault
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