-
Notifications
You must be signed in to change notification settings - Fork 10.3k
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gatsby-plugin-google-gtag window.gtag not working #12680
Comments
@jsbrain Mind reader is busted today, can you manually provide details for debugging (I know, I know, it's archaic). |
@coreyward Yeah, that's what I thought reading the docs of the plugin. The plugin says:
And I am trying something like: componentDidMount () {
window.gtag('event', 'click', { ...data })
} but it says that window.gtag is undefined. So obviously I'm misunderstanding something or the docs are misleading. Thank you |
Btw in case this question comes up: Yes, I tested in production ;) |
@jsbrain Just tried this out Here's what I added to
And I added a log in the index page component in the starter (this will be run after mount just like componentDidMount in your comment)
Can you link to your repository or try to make a minimal reproduction of this issue? That would help us track it down and help you resolve it. |
Hello I am experiencing the same issue, heres my config since i dont see anyone elses posted {
resolve: 'gatsby-plugin-google-gtag',
options: {
trackingIds: ["UA-XXXXXXXX"],
pluginConfig: {
head: true,
respectDNT: true,
},
},
}, and im using the window.gtag like this and im getting
NOTE: I also tried head: false and that did not work wither |
Hi @sidharthachatterjee , thank you for your help. I was able to resolve the issue. My browser cache was serving me an old version of my site 🤦♂️ So I removed all application data from chrome and voila it worked! @jcursoli Make sure to run in production mode (eg. |
@jsbrain Yes i tried it in production, cleared cache etc. |
Okay i think i got it, the problem is when you specify |
@jcursoli Just tested out setting |
Hi, I'm trying to send a custom event with the gatsby-plugin-google-gtag plugin.
But window.gtag is not available. I really don't get it. What am I doing wrong?
Thanks
The text was updated successfully, but these errors were encountered: