angularytics icon indicating copy to clipboard operation
angularytics copied to clipboard

Added sanity check: is Google Analytics loaded?

Open harmenjanssen opened this issue 9 years ago • 0 comments

This is just a very small tweak that makes sure ga is actually defined before calling it.
Since Google Analytics is typically loaded asynchronously and sometimes even by Google Tag Manager which itself is loaded asynchronously, it's possible for ga to be late to the party.

This oughtta make sure we never call an undefined function.

By the way: I'm not sure why my dist version includes comments where yours doesn't. I built using the supplied Gruntfile in the main repo. If you have any idea how to fix that I'll gladly edit my pull request.

harmenjanssen avatar Apr 02 '15 20:04 harmenjanssen