google-analytics-module: Analytics module not working in production mode
Version
Reproduction link
https://codepen.io/d–c/pen/rNNLXRq?editors=0010
Steps to reproduce
In development mode, with the debug code the script works fine. In production, I do not get any hits.
googleAnalytics: {
id: "UA-147623000-1"
}
What is expected ?
Hits in production mode
What is actually happening?
No hits in production mode.
Additional comments?
I did contemplate just leaving it in dev mode enabled:true but then the console is riddled with info which I do not wish to be seen by the user. I am using Nuxt v 2.10.1.
Do I need to change the ‘Mode’ in my Nuxt.config.js? Or shallI just use the Plugin method available on the official docs? https://nuxtjs.org/faq/google-analytics/
<div align="right">This bug report is available on Nuxt community (#c47)</div>About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 24
- Comments: 22 (3 by maintainers)
Commits related to this issue
- fix: send hits in production mode by default (#60) — committed to nuxt-community/google-analytics-module by manniL 5 years ago
- Trying to follow the solution described in this GitHub issue thread: https://github.com/nuxt-community/google-analytics-module/issues/60#issuecomment-545533186 — committed to josepcrespo/nuxt-vuetify-pwa-demo by josepcrespo 3 years ago
@ricardogobbosouza When will the next version be published? I am using the top-level option so in the meantime should I just do this:
We should not need to manually set
sendHitTaskto true though. It sounds like something in Nuxt 2.10+ changed with regards to determining if we are in dev or prod, so this is no longer sending hits.BROKEN, even when downgrading to 2.9.2!
same here “@nuxtjs/google-analytics”: “^2.2.0”, “nuxt”: “^2.10.0”,
vue-analytics by default sets sendHitTask to true. Not sure why, in the Nuxt module wrapper, this property has been set to undefined. Doesn’t make any sense to me
VueAnalytics Nuxt version: https://github.com/nuxt-community/analytics-module/blob/master/lib/module.js#L7 VueAnalytics Original version: https://github.com/MatteoGabriele/vue-analytics/blob/master/src/config.js#L44
In production using
with the module setting
I can confirm the google analytics tracking script does not work.
However, if I change the module setting to
as @manniL showed above the tracking script works again in production.
Not working either nuxt 2.6.3 & nuxtjs/google-analytics 2.2.0 weird because stopped working just 3 days ago.
adding this resolved it for me too