Activities

termorrell

termorrell posted a new bug report

analytics-module •

bug 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.

madsh93

madsh93 posted a new question

analytics-module •

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?

madsh93

madsh93 posted a new question

analytics-module •

this.$ga.set is send 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?

jb-alvarado

jb-alvarado posted a new question

analytics-module •

Opt-In

Hello,
I need some help from you. In Europa users have to opt-in for google analytics and this I try to realize with nuxtjs/google-analytics.

I thought I deactivate the module by default:

buildModules: [
        '@nuxtjs/google-analytics'
    ],

    googleAnalytics: {
        id: 'UA-1111111',
        set: [
            { field: 'anonymizeIp', value: true }
        ],
        disabled: true
    },

And in my Footer.vue component, where I have my cookie banner, I integrate the function to opt-in:

<template>
    <div id="footer">
        ...
        <b-button class="btn-left" @click="setCookieLaw(false)">
            Essenzielle Cookies
        </b-button>
        <b-button class="accept" @click="setCookieLaw(true)">
            OK
        </b-button>
        ...
    </div>
</template>

<script>
export default {
    ...
    created () {
        this.initCookieLaw()
    },

    methods: {
        setCookieLaw (useAnalytics) {
            this.$cookies.set('useAnalytics', useAnalytics, {
                path: '/',
                maxAge: 60 * 60 * 24 * 365
            })

            if (useAnalytics && process.client) {
                this.$ga.enable()
            } 

        },
        initCookieLaw () {
            const analytics = this.$cookies.get('useAnalytics')

            if (analytics && process.client) {
                this.$ga.enable()
            }
        }
    }
}
</script>

With this way I have now following situation:

  • I load the page, the banner come up and I hit ok. After that I navigate trough the page and this gets tracked
    • the problem with that is to, that the first page gets not tracked
  • but when I reload the page the debugging from analytics module says that the user had opt-out, so it is not possible to track

If I integrate a button some where in the page which call initCookieLaw(), the module is opt-in again. So why I can not initialize the enable functions after a page reload?

Do I have a misconception here?

silgon

silgon posted a new question

analytics-module •

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!

jssouders

jssouders posted a new question

analytics-module •

Which module to use for Google Analytics

I have a new NUXT application that needs to have Google Analytics integrated within the application. It appears that there is a very stable analytics-module (https://www.npmjs.com/package/@nuxtjs/google-analytics), but it is utilizing the analytics.js script that Google no longer recommends. Google currently recommends using gtag.js script for integrating with Google Analytics. The only package in the NUXTJS community is the google-gtag (https://www.npmjs.com/package/@nuxtjs/google-gtag) module. Is this the currently recommended module to use when integrating with Google Analytics? It appears that this package is not downloaded that frequently or released that often compared to analytics-module. Any help in the right direction would be appreciated.

carrera

carrera posted a new question

analytics-module •

Screenview tracking metrics are set to zero

My screens are not tracked, but my settings seem to be alright.

nuxt.config.js

['@nuxtjs/google-analytics', { id: process.env.ANALYTICS_ID, autoTracking: { page: false, screenview: true, exception: true, // pageviewOnLoad: false, }, debug: { enabled: true, sendHitTask: true } }],

edwh

edwh posted a new question

analytics-module •

Anonymise IP

Hi there - thanks for the module.

How do you enable the setting to anonymise IPs? There are instructions for vue-analytics at https://github.com/MatteoGabriele/vue-analytics/issues/64 which say:

beforeFirstHit () {
Vue.$ga.set('anonymizeIp', true)
}

…but I'm not sure how that would work when the configuration is inside nuxt.config.

Importing Vue into nuxt.config seems to work, and the debug logs suggest that it does:

Running command: ga("set", "anonymizeIp", true)

…but I want to be sure I'm not missing something.

LukaHarambasic

LukaHarambasic posted a new question

analytics-module •

Usage with a cookie banner

Hi,

I want to embed a typical cookie banner and only if the users clicks "Accept" GA should be loaded. How can I realize this?
The website will be hosted in Europe so it must be GPDR compliant.

Thank you,
Luka

mkstix6

mkstix6 posted a new question

analytics-module •

Trouble with advice to install @nuxtjs/google-analytics as devDependency

I installed @nuxtjs/google-analytics version 2.2.1 using the advice on:
https://www.npmjs.com/package/@nuxtjs/google-analytics
…which was to use:
yarn add --dev @nuxtjs/google-analytics

But when I deploy our app in "production" mode the module is then not install as per npm's documentation about devDependencies and production environments, here:
https://docs.npmjs.com/cli/install

I am unsure about deviating from the @nuxtjs/google-analytics documentation but…
Do I really need to make this module a devDependency?

Secondly, would it not be better to advise people to install with:
yarn add @nuxtjs/google-analytics

Sorry if I'm misunderstanding something here.

Thanks
Mark

MrZordex

MrZordex posted a new question

analytics-module •

Firefox private browsing

When I open my page in private firefox window I get the following error:

An error occured! Please check your connection, if you have any Google Analytics blocker installed in your browser or check your custom resource URL if you have added any.

Firefox claims it's a "feature" but how can I check whether my requests are blocked or not?

joska

joska posted a new question

analytics-module •

GA object not available in SSR

Hi, I would like to ask for a piece of advice. Even After hours I just can get vue-analytics events to run in universal mode - the this.$ga object always returns undefined whenever used inside the component.

I would be glad for any help.

Thank you
Josef

nuxt.config.js

modules: [
    ['@nuxtjs/google-analytics', {
      id: 'UA-130767453-1'
    }]
  ],
 googleAnalytics: {
    id: 'UA-130767453-1',
    commands: {
      showArchive () {
        this.$ga.event('clicks', 'click', 'archive', '')
      },
      nextEvent (name = 'unknown') {
        this.$ga.event('clicks', 'click', 'event-download', name)
      },
      saveTheDate (name = 'unknown') {
        this.$ga.event('clicks', 'click', 'save-the-date-download', name)
      }
    }
  },
  debug: {
    enabled: true,
    sendHitTask: true
  },

component

<a v-ga="$ga.commands.nextEvent.bind(this, name)" :href="eventLink" class="btn btn-primary btn-block">Add to calendar</a>

package.json

"version": "2.9.2",
"vue-analytics": "5.17.2",
"@nuxtjs/google-analytics": "2.2.1",
vunv-1219

vunv-1219 posted a new question

analytics-module •

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.!

xdcha

xdcha posted a new bug report

analytics-module •

bug 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/

mehidi258

mehidi258 posted a new question

analytics-module •

UTM parameters are not tracking without page reload.

I am using analytics-module with this option normal page views are tracking was working perfectly but UTM parameters are not working without page reload.
{ id: process.env.NUXT_ENV_GTAG_ID, config: { anonymize_ip: true, send_page_view: true }, debug: process.env.NODE_ENV === "production" ? false : true, disableAutoPageTrack: false }

redLineColor

redLineColor posted a new question

analytics-module •

Disable plugin programmatically

Hello,
I integrate this module using the documentation and i read https://matteogabriele.gitbooks.io/vue-analytics/content/docs/opt-out.html on how to disable the plugin.
Because I use nuxtjs config file i just add

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

If an user enter on my website, a popup will show to accept cookie consent and a cookie will be set. User can disable tracking libraries like google, facebook, etc, but i don't understand how i can disable this module if user choose to not been tracking.

On documentation the above example should work

Vue.use(VueAnalytics, {
id: 'UA-XXX-X',
disabled: () => {
return true
}
})

but i don't understand how to obtain that using nuxtjs.

I wanna make function like:

Vue.use(VueAnalytics, {
id: 'UA-XXX-X',
disabled: () => {
return this.$cookies.get('cookie-tracking-disabled') === true
}
})

daveatfuse

daveatfuse posted a new question

analytics-module •

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?

codeofsumit

codeofsumit posted a new question

analytics-module •

Module not sending to GA anymore

Since a few days my site using this module does not send to GA anymore. Locally I can also not see anything sent nor trigger the realtime info in the Google Analytics dashboard.

Once I enable sendHitTask it works again.

    '@nuxtjs/google-analytics',
      {
        id: 'UA-118133246-14',
        debug: {
          enabled: false,
          sendHitTask: true
        },
      },

is that normal?

Bildschirmfoto 2019-09-11 um 10.23.39.png

arkhamvm

arkhamvm posted a new question

analytics-module •

How to add `require` `displayfeatures` ?

Hi. How i can add ga('require', 'displayfeatures'); ?

kaboume

kaboume posted a new feature request

analytics-module •

idea 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.GOOGLEANALYTICSID,
debug: {
enabled: false,
sendHitTask: true
}
},

If you know why….