I'm using Sentry.io to detect javascript errors on my site.

I've noticed a bunch of Javascript errors, that originate from google_analytics.js which comes from this module:

"Can't find variable: gtag"

"gtag is not defined"

Is there any known fixes for this? My guess it's a race-condition.

Comments

ras-ben created an issue. See original summary.

ras-ben’s picture

StatusFileSize
new495 bytes

Well, I have no idea why this is happening, but this is a symptom-fix patch. It doesnt actually fix the illness.

This patch checks if gtag() exists, and if it does, it doesnt set any eventlisteners in the javascript.

ras-ben’s picture

StatusFileSize
new495 bytes
teebo’s picture

For those who encounter this issue... in my case it was simply because of the GDPR/Cookie acceptance.
By refusing or denying tracking, Google Analytics JS is not loaded.

japerry’s picture

Status: Active » Closed (outdated)

With the sunset of legacy google analytics, the 8.x-3.x module is now unsupported. If this is still an issue with the 4.x version, please file a new issue in the queue.