Giter Club home page Giter Club logo

google-analytics-module's Introduction

@nuxtjs/google-analytics

**⚠ WARNING: This package does not support GA4. **
This package currently only supports GA3/UA

@nuxtjs/google-analytics

npm version npm downloads Github Actions CI Codecov License

Google Analytics integration for Nuxt 2 using vue-analytics.

Nuxt 3

If you need Nuxt 3 support can use the alternative module nuxt-gtag.

Features

  • Automatic page tracking
  • Event batching
  • User timings
  • Screen view
  • Multiple domain ID
  • Automatic Google Analytics script loading
  • E-commerce support

📖  Read more

Contributing

  1. Clone this repository
  2. Install dependencies using yarn install or npm install
  3. Start development server using yarn dev or npm run dev

License

MIT License

Copyright (c) Nuxt Community

google-analytics-module's People

Contributors

atinux avatar clarkdo avatar cobyn avatar dependabot[bot] avatar frozire avatar greegus avatar harlan-zw avatar joaopedroas51 avatar mannil avatar matteogabriele avatar mayashavin avatar megos avatar pi0 avatar redidizzy avatar renovate[bot] avatar ricardogobbosouza avatar rlam3 avatar skyatura avatar syonip avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-analytics-module's Issues

Cannot install via npm

npm i @nuxtjs/google-analytics
npm WARN package.json [email protected] assert is also the name of a node core module.
npm WARN package.json [email protected] buffer is also the name of a node core module.
npm WARN package.json [email protected] events is also the name of a node core module.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] scripts['tests'] should probably be scripts['test'].
npm WARN package.json [email protected] scripts['tests'] should probably be scripts['test'].
npm WARN package.json [email protected] punycode is also the name of a node core module.
npm WARN package.json [email protected] querystring is also the name of a node core module.
npm WARN package.json [email protected] string_decoder is also the name of a node core module.
npm WARN package.json [email protected] url is also the name of a node core module.
npm WARN package.json [email protected] util is also the name of a node core module.
npm WARN package.json [email protected] No repository field.
npm ERR! 404 Not Found
npm ERR! 404
npm ERR! 404 'nuxtjs/google-analytics' is not in the npm registry.
This question is available on Nuxt.js community (#c7)

Timing issue with vue-meta

pageviewTemplate is resolved before vue-meta has synced the page components head.

Reproduce:

  1. Download Nuxt.js starter template
  2. Install analytics module and set pageviewTemplate:
// nuxt.config.js
'google-analytics': {
  id: 'UA-XXXXXX',
  debug: {
    enabled: true,
  },
  autoTracking: {
    pageviewTemplate: route => {
      return {
        page: route.path,
        title: document.title,
        location: window.location.href,
      };
    },
  },
},
  1. Setup two pages:
<!-- pages/page1.vue -->
<template>
  <div>
    <h1 class="title">Page 1</h1>

    <div class="links">
      <nuxt-link to="page1">Page 1</nuxt-link>
      <nuxt-link to="page2">Page 2</nuxt-link>
    </div>
  </div>
</template>

<script>
export default {
  head() {
    return {
      title: 'Page 1',
    };
  },
}
</script>
<!-- pages/page2.vue -->
<template>
  <div>
    <h1 class="title">Page 2</h1>

    <div class="links">
      <nuxt-link to="page1">Page 1</nuxt-link>
      <nuxt-link to="page2">Page 2</nuxt-link>
    </div>
  </div>
</template>

<script>
export default {
  head() {
    return {
      title: 'Page 2',
    };
  },
}
</script>

Expected behavior:
Page 1 will track "Page 1" as title
Page 2 will track "Page 2" as title

Actual behavior:
Page 1 & Page 2 tracks title correctly during initial load
Page 2 tracks "Page 1" when changing route from Page 1 -> Page 2
Page 1 tracks "Page 2" when changing route from Page 2 -> Page 1

Console output:

location         (&dl)   http://localhost:3000/page2
page             (&dp)   /page2
title            (&dt)   Page 1
location         (&dl)   http://localhost:3000/page1
page             (&dp)   /page1
title            (&dt)   Page 2
This question is available on Nuxt.js community (#c8)

Cacheable Option or Async analytics

What problem does this feature solve?

pagespeed insight optimization suggestion.

What does the proposed changes look like?

It would swap out analytics js to galite when cache: true

Just thought that it would be a good idea to have this in main analytics module of nuxt.

Thanks

This feature request is available on Nuxt community (#c31)

Nuxt Analytics not working when building with yarn generate

Version

2.3.0

Reproduction link

https://gist.github.com/termorrell/72a2c6f3a8dc926c7c46953e57f1ca94

Steps to reproduce

I have added the analytics module following the documentation in the README.

export default {
...
buildModules: [
    ['@nuxtjs/google-analytics', {
      id: 'UA-********-**'
    }],
  ],
...
}

Running when running yarn generate I cannot see any events firing to Google Analytics. This is also the case when adding the debug: enabled flag to true.

What is expected ?

When building the site with yarn generate I would expect to see the events firing to Google Analytics.

What is actually happening?

No events are being fired. I can see my GA ID in the compiled Nuxt JS but they are not appearing in network requests and not appearing in the GA dashboard.

This bug report is available on Nuxt community (#c60)

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organiszation’s settings page, under Installed GitHub Apps.

This question is available on Nuxt.js community (#c2)

Analytics not loading and disabling css module

Version

2.2.0

Reproduction link

https://github.com/sebastianmarines/maz/

Steps to reproduce

Install google analytics

yarn install @nuxtjs/google-analytics

Add module to nuxt.config.js

modules: [
    '@nuxtjs/bulma',
    ['@nuxtjs/google-analytics', {
       id: 'UA-12301-2'
     }]
  ],

What is expected ?

Analytics module should load

What is actually happening?

The css module is being blocked from loading and the analytics module is not loading

This bug report is available on Nuxt community (#c38)

Works locally, but not in production

I'm trying to figure out what the issue could be here. I followed the very simple setup instructions as outlined on this repo (npm i --save @nuxtjs/google-analytics), and adding it to the nuxt.config.js modules array.

When I run npm run build and npm run start locally, the analytics "real time" shows my footprint on the site.

When I pushed the code to the production server, ensured npm installed the dependency, reran npm run build / start -- nothing. No errors (even when ran in dev mode), and it's not showing my real time footprint in GA. In GA for the property settings, I have it set to use the correct URL https://mysite.com..

Any ideas?

This question is available on Nuxt community (#c29)

this.$ga.set is sent when leaving a page

Hi

I have set up following code:

created() {
this.$ga.set({
dimension1: this.productId,
dimension2: 'offerdetail'
})
}

However, it seems to only fire on initial launch. But then it fires when leaving the page. I have tried to describe the process below.

Initial load/Enter product page(ID: 1) (dimension1 == 1)
Enter front page (dimension1 == 1)
Enter new product page(ID: 2) (dimension1 == 1)
Enter front page (dimension1 == 2)

I have tried using both created() and mounted(). Am I doing something wrong?

This question is available on Nuxt community (#c59)

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/

This bug report is available on Nuxt community (#c47)

Support for GA4

The next generation of Google Analytics was launched this week. It's called Google Analytics 4. I don´t see any mentions of it on your documentation.

Need ability to disable in development

I don't see a config to disable this module in development. Current workaround is to set the env var as UA-000000-1, but this is not ideal.

With missing GA code, the following error returns in development:

client.js:533 [nuxt] Error while initializing app Error: [vue-analytics] Please enter a Google Analytics tracking ID
    at A (http://localhost:3000/_nuxt/vendor.js:19078:4201)
    at I (http://localhost:3000/_nuxt/vendor.js:19078:5605)
    at Function.Vue.use (http://localhost:3000/_nuxt/vendor.js:28179:14)
    at _callee$ (http://localhost:3000/_nuxt/app.js:1270:58)
    at tryCatch (http://localhost:3000/_nuxt/vendor.js:2017:40)
    at Generator.invoke [as _invoke] (http://localhost:3000/_nuxt/vendor.js:2251:22)
    at Generator.prototype.(anonymous function) [as next] (http://localhost:3000/_nuxt/vendor.js:2069:21)
    at step (http://localhost:3000/_nuxt/vendor.js:1832:30)
    at http://localhost:3000/_nuxt/vendor.js:1850:14
    at new Promise (<anonymous>)
This question is available on Nuxt.js community (#c9)

npm run test does not work

Version

master

Reproduction link

#16

Steps to reproduce

  1. git clone this repo
  2. npm i
  3. npm test

What is expected ?

I expect that tests will be executed without any errors.

What is actually happening?

Tests fail.
Output:

» npm run test

> @nuxtjs/[email protected] test /Users/sobolev/Desktop/analytics-module
> npm run lint && jest


> @nuxtjs/[email protected] lint /Users/sobolev/Desktop/analytics-module
> eslint lib src test

  console.error node_modules/nuxt/lib/core/nuxt.js:166
    Error: [nuxt] Module undefined should export a function
        at ModuleContainer.addModule (/Users/sobolev/Desktop/analytics-module/node_modules/nuxt/lib/core/module.js:113:13)
        at promise.then (/Users/sobolev/Desktop/analytics-module/node_modules/nuxt/lib/common/utils.js:61:61)
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:160:7)

Build completed in 12.375s% 

  console.log node_modules/progress-bar-webpack-plugin/node_modules/progress/lib/node-progress.js:179
    

  console.log node_modules/progress-bar-webpack-plugin/node_modules/progress/lib/node-progress.js:179
    

  console.log node_modules/friendly-errors-webpack-plugin/src/output.js:81
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    


  console.log node_modules/friendly-errors-webpack-plugin/src/output.js:103
     DONE  Compiled successfully in 12379ms                               2:40:38 PM

  console.log node_modules/friendly-errors-webpack-plugin/src/output.js:103
    

  console.log node_modules/nuxt/lib/builder/builder.js:485
    Hash: 129f262eedf51f4aaa86
    Version: webpack 3.12.0
    Time: 12379ms
                                      Asset       Size  Chunks             Chunk Names
        pages/index.d1944e94f3fa94fff074.js  410 bytes       0  [emitted]  pages/index
    layouts/default.cc1854ad9412fd1849aa.js  326 bytes       1  [emitted]  layouts/default
             vendor.a6e76812813970cf0d37.js     144 kB       2  [emitted]  vendor
                app.07d83a8721058ce9e65d.js      26 kB       3  [emitted]  app
           manifest.129f262eedf51f4aaa86.js    1.47 kB       4  [emitted]  manifest
                                   LICENSES  584 bytes          [emitted]  
     + 3 hidden assets

 FAIL  test/module.test.js (17.236s)
  Module
    ✕ render (30ms)

  ● Module › render

    StatusCodeError: 404 - "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Cannot GET /</pre>\n</body>\n</html>\n"
      
      at new StatusCodeError (node_modules/request-promise-core/lib/errors.js:32:15)
      at Request.plumbing.callback (node_modules/request-promise-core/lib/plumbing.js:104:33)
      at Request.RP$callback [as _callback] (node_modules/request-promise-core/lib/plumbing.js:46:31)
      at Request.self.callback (node_modules/request/request.js:186:22)
      at Request.<anonymous> (node_modules/request/request.js:1163:10)
      at IncomingMessage.<anonymous> (node_modules/request/request.js:1085:12)

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |        0 |        0 |        0 |        0 |                   |
----------|----------|----------|----------|----------|-------------------|
Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        17.878s
Ran all test suites.
  console.log node_modules/nuxt/lib/builder/builder.js:485
    Hash: 0b33a0986a0638a57d72
    Version: webpack 3.12.0
    Time: 604ms
                 Asset    Size  Chunks             Chunk Names
    server-bundle.json  112 kB          [emitted]  

  console.log node_modules/nuxt/lib/core/nuxt.js:126
    
     OPEN  http://localhost:5060
    

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @nuxtjs/[email protected] test: `npm run lint && jest`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @nuxtjs/[email protected] test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/sobolev/.npm/_logs/2018-05-15T11_40_40_668Z-debug.log

Additional comments?

My env:

  • Node: v9.4.0
  • Npm: 5.6.0
This bug report is available on Nuxt.js community (#c16)

Support runtimeConfig

What problem does this feature solve?

In order to attend 12factor, the module should use the new runtimeConfig feature.

This feature request is available on Nuxt community (#c65)

Can't load tracking code ID as enviroment variables

I was hoping to be able to load my tracking code as an environment variable. It seems that the variables on production aren't loaded before the module is initialised. I am deploying with Netlify so I don't know if it's there issue...

IN this screenshot I am logging;

  • Current enviroment
  • The tracking code ID from my .env.production
  • GA debugging is enabled and you can see it's using my development/fallback ID UA-000000-1

screen shot 2018-03-24 at 21 05 11

This question is available on Nuxt.js community (#c10)

Dynamic id

Hello,
How can I put id dynamically ? I use a custom api module wich retrive some information such as the google analytics id, but it is called in a middleware.
I see that in vue-analytics I can put a Promise instead of the id, but I just want to take the id in my store, I don't want to perform another request, because requests have to be done through the plugin I created, and because I already do that for verification pourpose in the middleware
I try to do that, but google tag assistant doesn't see th UA code:
nuxt.config.js

{src: '~/plugins/vue-analytics.js', ssr: false},

/plugins/vue-analytics.js

import Vue from 'vue'
import VueAnalytics from 'vue-analytics'

export default ({ store }) => {
  Vue.use(VueAnalytics, {
    id: store.state.descs.google_analytics,
    ecommerce: {
      enabled: true
    }
  })
}
This question is available on Nuxt.js community (#c12)

No registrations from prod and Google Tag Assistant can't find analytics in prod

Version

v2.4.0

Reproduction link

https://www.raddadjuren.se

Steps to reproduce

Checking Google Tag Assistant in production on https://www.raddadjuren.se

What is expected ?

I expect Google Tag Assistant to find an analytics tag and be able to record analytics events.

What is actually happening?

However, analytics does not seem to be present in production. Google Tag Assistant does not report any events or tracking.

Additional comments?

Production is a static deploy on Netlify built with Nuxt 2.14.3.

Analytics works in dev and Google Tag Assistant can detect the tag and record events and tracking in dev.

nuxt/analytics is set up as a buildModule with the following toplevel config:

googleAnalytics: {
id: 'UA-REDACTED',
debug: {
enabled: true,
sendHitTask: true
}
},

This might well be a configuration error on my part and I will continue to look into this.

Any ideas on how to debug this is very welcome.

This bug report is available on Nuxt community (#c71)

Nuxt Analytics & PWA (service worker)

What problem does this feature solve?

After installed the nuxt PWA module in my nuxt application, my application stopped to send the data to Google Analytics (whit the Nuxt Analytics module).
After many hours, I found a solution to let the module work again.
I had to add in the nuxt.config.js the sendHitTask like that

googleAnalytics: {
id: process.env.GOOGLE_ANALYTICS_ID,
debug: {
enabled: false,
sendHitTask: true
}
},

If you know why....

This feature request is available on Nuxt community (#c41)

why buildModules instead of modules ?

I'm just trying to understand the logic why this module needs to be inside buildModules instead of modules ? It seems that buildModules is generalyl designed for things that only occur during the build, yet something like google analytics which (I would imagine) can execute code on every route change doesn't feel like it should be a "build-only" module ?

Google Analytics 4 properties

The new Google Analytics 4 properties seems not to be supported by gooogle-analytics-module.

The new Google Analytics tracking Id looks like this: G-XXXXXXX

When trying to add it i get the following error:
"analytics_debug.js:25 The tracking Id should only be of the format UA-NNNNNN-N."

How can we fix this?

Google analytics id not added to pages

Version

2.2.0

Reproduction link

https://github.com/syonip/nuxt-ga-bug

Steps to reproduce

npx create-nuxt-app nuxt-test
cd nuxt-test
npm i @nuxtjs/google-analytics

add following to nuxt.config.js:

modules: [
    ['@nuxtjs/google-analytics', {
      id: 'UA-****'
    }]
  ]

run

npm run dev

What is expected ?

I expect to see activity in GA realtime page.
I expect the html page to contain the 'UA-****' string somewhere but it doesn't.

What is actually happening?

I don't see any activity in GA realtime page when browsing to localhost:3000.
Generated html contains <script async="" src="https://www.google-analytics.com/analytics.js" charset="utf-8"></script> but not the required call to gtag function with my id.

This bug report is available on Nuxt community (#c37)

Events not working if enabling GA in component

Events are not sending, if i enable GA in mounted hook on second load. But it works on first page load, when i click button Accept

<template>
  <div v-if="isOpen" class="cookie">
    <div class="container">
      <div class="cookie__wrap">
        <div class="cookie__content">
          This site uses cookies, as explained in our
          <nuxt-link :to="localePath({ name: 'privacy-policy' })"
            >cookie policy</nuxt-link
          >.<br />
          If you agree to our use of cookies, please accept this message and
          continue to use this site
        </div>
        <button class="btn--secondary" type="button" @click="accept">
          Accept
        </button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'CookieMessage',
  data() {
    return {
      isOpen: false,
    }
  },
  mounted() {
    if (!this.getGDPR() === true) {
      this.isOpen = true
    } else {
        this.$gtm.init()
        this.$ga.enable()
    }
  },
  methods: {
    getGDPR() {
      if (process.browser) {
        return localStorage.getItem('GDPR:accepted', true)
      }
    },
    accept() {
      if (process.browser) {
        this.isOpen = false
        localStorage.setItem('GDPR:accepted', true)
        this.$gtm.init()
        this.$ga.enable()
      }
    },
  },
}
</script>

Migrate from analytics.js to gtag.js

Hi,

We know that google migrate implementation analytics from analytics.js to gtag.js (src: https://developers.google.com/analytics/devguides/collection/gtagjs/migration).

So is this module support to gtag.js?

Because this module is using vue-analytics and in this issue, MatteoGabriele said that vue-analytics didn't yet support gtag.js.

Or, is there any solution to implementing "new" google analytics with gtag.js?

thanks

This question is available on Nuxt.js community (#c6)

Analytics module bug on error pages

On 404 pages (using layouts/error.vue) I'm seeing the following in the console:

vue-router.esm.js:1832 TypeError: Cannot read property 'components' of undefined
    at i (google-analytics.plugin.76c7bae6.js:33)
    at google-analytics.plugin.76c7bae6.js:20
    at vue-router.esm.js:1926
    at Array.forEach (<anonymous>)
    at e.te.updateRoute (vue-router.esm.js:1925)
    at vue-router.esm.js:1802
    at vue-router.esm.js:1911
    at r (vue-router.esm.js:1649)
    at at (vue-router.esm.js:1660)
    at vue-router.esm.js:1906
This question is available on Nuxt.js community (#c1)

I cannot make it working

I installed the package as specified yarn add --dev @nuxtjs/google-analytics
The following code:

  buildModules: [
    ['@nuxtjs/google-analytics', {
      id: 'UA-12301-2' // with my real id instead
    }]
  ]

I put it in export default or/and module.exports and it doesn't work. When I build the application and I put it in the server, there are no calls to google analytics.

For reference, the important part of the package.json file:

  "scripts": {
    "dev": "nuxt --hostname 0.0.0.0",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
    "precommit": "npm run lint"
  },
  "dependencies": {
    "@nuxtjs/axios": "^5.9.5",
    "bootstrap-vue": "^2.4.1",
    "downloadjs": "^1.4.7",
    "html-loader": "^0.5.5",
    "nuxt": "^2.11.0",
    "nuxt-i18n": "^6.5.0",
    "vue-scrollto": "^2.17.1"
  },
  "devDependencies": {
    "@nuxtjs/eslint-module": "^1.1.0",
    "@nuxtjs/google-analytics": "^2.2.3",
    "babel-eslint": "^10.0.1",
    "eslint": "^4.19.1",
    "eslint-friendly-formatter": "^4.0.1",
    "eslint-loader": "^2.1.1",
    "eslint-plugin-vue": "^4.0.0"
  }

Any guidance is appreciated, thanks!

This question is available on Nuxt community (#c56)

Add asyncID to document

What problem does this feature solve?

asyncID is awesome, we can set ID dynamic from API.

This feature request is available on Nuxt community (#c69)

Feature proposal: Allow ga's id be a function

I have a server that is used for different domains. I want to for each domain it uses a different ga id.
Example of use case:

{
  modules: [
    // Simple usage
    ['@nuxtjs/google-analytics', {
      id: () => {
        switch (document.domain) {
          case 'github.com':
            return 'UA-12301-2';
          case 'foo.com':
            return 'UA-12301-3';
          default:
            return 'UA-12301-4';
        }
      }
    }]
 ]
}
This question is available on Nuxt community (#c27)

How do you even start this?

followed the instructions and this happens.

I also did npm install vue-analytics

ERROR Nuxt error

Error: Cannot resolve "@nuxtjs/google-analytics" from "/home/jerico/public_html/jerico.xyz/client/nuxtjs/google-analytics"

  • nuxt.js:220 Nuxt.resolvePath
    [jerico.xyz]/[nuxt]/lib/core/nuxt.js:220:11

  • module.js:114 ModuleContainer.addModule
    [jerico.xyz]/[nuxt]/lib/core/module.js:114:35

  • utils.js:96 promise.then
    [jerico.xyz]/[nuxt]/lib/common/utils.js:96:43

  • next_tick.js:188 process._tickCallback
    internal/process/next_tick.js:188:7

  • module.js:686 Function.Module.runMain
    module.js:686:11

  • bootstrap_node.js:187 startup
    bootstrap_node.js:187:16

  • bootstrap_node.js:608

This question is available on Nuxt.js community (#c3)

npm run test does not work

Steps to reproduce

  1. git clone this repo
  2. npm i
  3. npm test

Env

Node: v9.4.0
Npm: 5.6.0

Output

» npm run test

> @nuxtjs/[email protected] test /Users/sobolev/Desktop/analytics-module
> npm run lint && jest


> @nuxtjs/[email protected] lint /Users/sobolev/Desktop/analytics-module
> eslint lib src test

  console.error node_modules/nuxt/lib/core/nuxt.js:166
    Error: [nuxt] Module undefined should export a function
        at ModuleContainer.addModule (/Users/sobolev/Desktop/analytics-module/node_modules/nuxt/lib/core/module.js:113:13)
        at promise.then (/Users/sobolev/Desktop/analytics-module/node_modules/nuxt/lib/common/utils.js:61:61)
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:160:7)

Build completed in 12.375s% 

  console.log node_modules/progress-bar-webpack-plugin/node_modules/progress/lib/node-progress.js:179
    

  console.log node_modules/progress-bar-webpack-plugin/node_modules/progress/lib/node-progress.js:179
    

  console.log node_modules/friendly-errors-webpack-plugin/src/output.js:81
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    


  console.log node_modules/friendly-errors-webpack-plugin/src/output.js:103
     DONE  Compiled successfully in 12379ms                               2:40:38 PM

  console.log node_modules/friendly-errors-webpack-plugin/src/output.js:103
    

  console.log node_modules/nuxt/lib/builder/builder.js:485
    Hash: 129f262eedf51f4aaa86
    Version: webpack 3.12.0
    Time: 12379ms
                                      Asset       Size  Chunks             Chunk Names
        pages/index.d1944e94f3fa94fff074.js  410 bytes       0  [emitted]  pages/index
    layouts/default.cc1854ad9412fd1849aa.js  326 bytes       1  [emitted]  layouts/default
             vendor.a6e76812813970cf0d37.js     144 kB       2  [emitted]  vendor
                app.07d83a8721058ce9e65d.js      26 kB       3  [emitted]  app
           manifest.129f262eedf51f4aaa86.js    1.47 kB       4  [emitted]  manifest
                                   LICENSES  584 bytes          [emitted]  
     + 3 hidden assets

 FAIL  test/module.test.js (17.236s)
  Module
    ✕ render (30ms)

  ● Module › render

    StatusCodeError: 404 - "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Cannot GET /</pre>\n</body>\n</html>\n"
      
      at new StatusCodeError (node_modules/request-promise-core/lib/errors.js:32:15)
      at Request.plumbing.callback (node_modules/request-promise-core/lib/plumbing.js:104:33)
      at Request.RP$callback [as _callback] (node_modules/request-promise-core/lib/plumbing.js:46:31)
      at Request.self.callback (node_modules/request/request.js:186:22)
      at Request.<anonymous> (node_modules/request/request.js:1163:10)
      at IncomingMessage.<anonymous> (node_modules/request/request.js:1085:12)

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |        0 |        0 |        0 |        0 |                   |
----------|----------|----------|----------|----------|-------------------|
Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        17.878s
Ran all test suites.
  console.log node_modules/nuxt/lib/builder/builder.js:485
    Hash: 0b33a0986a0638a57d72
    Version: webpack 3.12.0
    Time: 604ms
                 Asset    Size  Chunks             Chunk Names
    server-bundle.json  112 kB          [emitted]  

  console.log node_modules/nuxt/lib/core/nuxt.js:126
    
     OPEN  http://localhost:5060
    

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @nuxtjs/[email protected] test: `npm run lint && jest`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @nuxtjs/[email protected] test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/sobolev/.npm/_logs/2018-05-15T11_40_40_668Z-debug.log


Nuxt Analytics multiples IDs

Hello! i have some issue to add an aditional ID in a specific page:

My Nuxt.config.js
modules: [
['@nuxtjs/google-analytics', { id: 'UA-XXXX-X' }],
],

Work as expected, tracking my pages.

But in a specific page i need to add another ID.
i already try to use all methods that i find in docs, but its doesn work for me

**> My method in a specific page:

import VueAnalytics from 'vue-analytics'
import Vue from 'vue'

startGoogleAnalytics () {
let gaCode = 'UA-' + this.event.google_analytics
Vue.use(VueAnalytics, {
id: gaCode
})**

im also try to use set option like:
this.$ga.set('userID', xxxxx)

but still not work for me

Could someone help me?
Thanks

Adding multiple items to a transaction

Not sure if this is a bug but I can't seem to find a way to implement adding multiple products to a transaction as per the https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce#sendingData

Setup:

Vue.use(VueAnalytics, {
				id: process.env.googleAnalyticsID,
				router,
				ecommerce: {
					enabled: true,
					enhanced: false,
				},
				debug:{
					enabled: true,
					sendHitTask: true
				}
			});

Request:

`this.$ga.ecommerce.addTransaction({
				id: this.id,
				revenue: "37.39", 
				currency: "NZD",
			});
		this.$ga.ecommerce.addItem([{
			name: "ClassCode - Description", // Product name. Required.
			category: "Vehicle",
			id: this.id, // Booking ID. Required.
			price: "11.99", // Unit price.
			days: "4", // HirePeriodInDays
			quantity: "1", // Quantity.
			currency: "NZD",
		}]);
		
		this.$ga.ecommerce.addItem({
			name: "Peace of Mind", // Product name. Required.
			category: "Insurance",
			id: this.id, // Booking ID. Required.
			price: "5.00", // Unit price.
			quantity: "1", // Quantity.
			currency: "NZD",
		});
		
		this.$ga.ecommerce.addItem({
			name: "Afterhours Pick up", // Product name. Required.
			category: "Other Fees",
			id: this.id, // Booking ID. Required.
			price: "5.00", // Unit price.
			quantity: "1", // Quantity.
			currency: "NZD",
		});
		
		this.$ga.ecommerce.addItem({
			name: "OneWay Fee", // Product name. Required.
			category: "Other Fees",
			id: this.id, // Booking ID. Required.
			price: "5.00", // Unit price.
			quantity: "1", // Quantity.
			currency: "NZD",
		});
		
		this.$ga.ecommerce.addItem({
			name: "Airport Concession Fee", // Product name. Required.
			category: "Other Fees",
			id: this.id, // Booking ID. Required.
			price: "5.00", // Unit price.
			quantity: "1", // Quantity.
			currency: "NZD",
		});
		
		this.$ga.ecommerce.addItem({
			name: "Accessory name", // Product name. Required.
			category: "Accessory",
			id: this.id, // Booking ID. Required.
			price: "5.00", // Unit price.
			quantity: "1", // Quantity.
			currency: "NZD",
		});

		this.$ga.ecommerce.send();`

I can see the collect request going through but only the transaction and last item is in there, I can get it working if I do a send() after adding each item but I doubt that's correct.

I have also tried passing in an array of items which was unsuccessful, and the addProduct function is not available in the non enhanced version. What is the correct way of handling this, or is it a bug?

This question is available on Nuxt community (#c44)

Allow ga's id be a function

What problem does this feature solve?

I have a server that is used for different domains. I want to for each domain it uses a different ga id.

What does the proposed changes look like?

{
  modules: [
    // Simple usage
    ['@nuxtjs/google-analytics', {
      id: () => {
        switch (document.domain) {
          case 'github.com':
            return 'UA-12301-2';
          case 'foo.com':
            return 'UA-12301-3';
          default:
            return 'UA-12301-4';
        }
      }
    }]
 ]
}
This feature request is available on Nuxt community (#c28)

How to use ignoreRoutes in modules option

I have some routes are /admin, /admin/1, /admin/2. And i do not want to send pageview if router change to these routes. I use option ignoreRoutes: ['/admin'], but it not working.
Sorry because my English is bad. I believe you can help me.!

This question is available on Nuxt community (#c48)

Programmatically enabling/disabling not working

Version

1

Reproduction link

https://codesandbox.io/s/kor57z1vy7

(Please use the extension Google Tag Manager to view the tag)

Steps to reproduce

Whenever you try to programmatically fire the $ga.enable/$ga.disable the tracking is still active

What is expected ?

That specific user should be disabled from being tracked in the real time tracking

What is actually happening?

The calls don't seem to do anything, they are initialized but not functioning.

This bug report is available on Nuxt community (#c36)

Use on SSR

can I use this module during SSR?
how can I trigger GA events from the server side?
eg: set the userId, or addImpression for ecommerce on a list of products.
or where should I take those codes? :)
thanks

This question is available on Nuxt.js community (#c14)

Support for Google Analytics Update

What problem does this feature solve?

Google's latest dynamic tagging solution, will you be supporting this?

What does the proposed changes look like?

(analytics.js) to the latest tag (gtag.js)

This feature request is available on Nuxt community (#c73)

Add github issue template

What problem does this feature solve?

When creating my first issue for this project I was not informed on how to do it properly.
Since there's no clean sign about using cmty.io.

So, for future contributors it would be very nice to add a template that states, that issues must be created on cmty.io.
Or they will be closed otherwise.

What does the proposed changes look like?

Related: #16

This feature request is available on Nuxt.js community (#c17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.