minified construct js can conflict with Google Analytics

0 favourites
  • 4 posts
From the Asset Store
Google Analytics 4 Plugin for Construct 3 enables metrics and analytics for your games easily.
  • I've been having a problem where mysteriously, Google Analytics wouldn't work with my game, but only when it was minified. As it turns out, with this particular game, my minified c2runtime.js includes a global variable named "ga". Unfortunately, Google Analytics uses "ga", so then i end up with conflicts and analytics stops working. When I run the exported game with the GA debugging extension, it tells me there's already an object named "ga" so errors may occur.

    This seems mostly hopeless, but is there any way to control what globals are used when the code is minified? And I realize I'm an edge case, but it would be nice if in the future construct could avoid colliding with popular code libraries when minifying.

  • I should also add so if it helps anyone, I was able to get it working by replacing all instances of "ga" in the minified c2runtime with another variable (I used "xx"). With Sublime Text, replacing with the regex ga(?![a-z]) case insensitive did the trick.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Good workaround. You might post that to the Bug forum. However I don't know if Ashley has direct control over the minifier's name choices,

  • That's very interesting to know.

    This is a predictable error that may often happen.

    Two letter variable names are things from the past.

    The minifier predicts correctly that noone else in the world is using those.


Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)