Skip to content
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

Analytics module not working in production mode #60

Closed
xdcha opened this issue Oct 17, 2019 · 22 comments
Closed

Analytics module not working in production mode #60

xdcha opened this issue Oct 17, 2019 · 22 comments

Comments

@xdcha
Copy link

xdcha commented Oct 17, 2019

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/

This bug report is available on Nuxt community (#c47)
@ghost ghost added the cmty:bug-report label Oct 17, 2019
@xdcha xdcha changed the title Not working in production mode Analytics module not working in production mode Oct 17, 2019
@cksho
Copy link

cksho commented Oct 17, 2019

same here
"@nuxtjs/google-analytics": "^2.2.0",
"nuxt": "^2.10.0",

@xdcha
Copy link
Author

xdcha commented Oct 17, 2019

Wonder if it is to do with the latest Nuxt?

@vana-dev
Copy link

same,

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

@tetreault
Copy link

confirming this isnt working on my end

@maiconpazin
Copy link

Same here.

@jake-101
Copy link

same here in nuxt 2.10

@mfrascati
Copy link

Same here. Downgrading nuxt to 2.9.2 works as temporary fix

@cliffordh
Copy link

BROKEN, even when downgrading to 2.9.2!

@DispatchCommit
Copy link

Confirmed broken in 2.10, working in 2.9.2

@manniL
Copy link
Member

manniL commented Oct 20, 2019

Use the "thumbs up" emoji on the actual issue instead of posting "same here", "broken" or similar. Thanks.

I can't reproduce it though with the latest nuxt-edge build.

Settings:

    ['@nuxtjs/google-analytics', {
      id: 'my-analytics-uid',
      debug: {
        sendHitTask: isProd // true
      },
      set: [
        { field: 'anonymizeIp', value: true }
      ]
    }],

I'd appreciate a CodeSandbox as reproduction.

@ryarturogi
Copy link

Not working either nuxt 2.6.3 & nuxtjs/google-analytics 2.2.0 weird because stopped working just 3 days ago.

@ryarturogi
Copy link

ryarturogi commented Oct 21, 2019

Im using GTM now after i saw this...
I tried using Google Tag Manager + Google Analytics with Nuxt.js

@xdcha
Copy link
Author

xdcha commented Oct 21, 2019

@manniL With respect, I am not sure a Code sandbox will be able to assist further. I simply install via command line and then reference as I did in my reproduction link. Are you saying the code should be as you have mentioned in your post?

Here is my package.json if it is of any use?

"scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate"
  },
  "dependencies": {
    "@nuxtjs/google-analytics": "^2.2.0",
    "huntjs": "^5.0.0",
    "lazysizes": "^5.1.2",
    "nuxt": "^2.10.1",
    "sniffer": "github:watsondg/sniffer",
    "vue-scrollto": "^2.17.1"
  },
  "devDependencies": {
    "coffee-loader": "^0.9.0",
    "coffeescript": "^2.4.1",
    "node-sass": "^4.12.0",
    "pug": "^2.0.3",
    "pug-plain-loader": "^1.0.0",
    "sass-loader": "^8.0.0"
  }

@sankhagowit
Copy link

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.

@xdcha
Copy link
Author

xdcha commented Oct 22, 2019

@manniL @sankhagowit Thanks so much both. I do have it working now. Thanks once more!!! :-)

@yooneskh
Copy link

adding this resolved it for me too

debug: {
  sendHitTask: true
}

@RobbieTheWagner
Copy link

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.

@MatteoGabriele
Copy link
Collaborator

MatteoGabriele commented Oct 22, 2019

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

@yooneskh
Copy link

yooneskh commented Oct 22, 2019 via email

@ricardogobbosouza
Copy link
Member

In prod mode sendHitTask will be set to true in next version 9c55a28

In dev mode sendHitTask is set to false

Note: By default, you won't see hits going out in dev mode. For testing analytics in dev mode, you must add the following to nuxt.config.js

https://github.com/nuxt-community/analytics-module#usage

@isaumya
Copy link

isaumya commented Oct 23, 2019

@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'
    }
  }

@pi0
Copy link
Member

pi0 commented Oct 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests