google-analytics-module: Analytics module not working in production mode

Version

2.2.0

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

Most upvoted comments

@ricardogobbosouza When will the next version be published? I am using the top-level option so in the meantime should I just do this:

googleAnalytics: {
    id: 'UA-1234567-8',
    debug: {
      sendHitTask: process.env.NODE_ENV !== 'development'
    }
  }

We should not need to manually set sendHitTask to 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

"nuxt": "^2.10.1",
"@nuxtjs/google-analytics": "^2.2.0" 

with the module setting

modules: [
    [
      "@nuxtjs/google-analytics",
      { id: "GA-ID-Here"}
    ]
]

I can confirm the google analytics tracking script does not work.

However, if I change the module setting to

modules: [
    [
      "@nuxtjs/google-analytics",
      { id: "GA-ID-Here"}, debug: { sendHitTask: true }
    ]
]

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

debug: {
  sendHitTask: true
}