Open DevineDecrypter opened 2 years ago
i have the same issue
@DevineDecrypter @BenGoetemann did you guys solve it? This.$ga is undefined for me
No I used vue gtag instead. If you're using Nuxt 2 you have to use vue gtag v1. I didnt use it for Nuxt 3.
If your using Nuxt 2 you have to register it as plugin in your nuxt.config. This is the plugin code:
import Vue from 'vue';
import VueGtag from 'vue-gtag';
export default ({
app, env
}) => {
Vue.use(VueGtag, {
bootstrap: false,
config: {
id: env.ANALYTICS_KEY,
params: {
anonymize_ip: true
}
},
appName: 'your app name',
}, app.router);
}
... and then you can use it via this.$gtag
inside your components.
Hope this helps!
I'm trying to use $ga in a middleware, but it doesn't seem to contain it. I tried using
context.$ga
andcontext.app.$ga
but they are undefined. I also tried putting'@nuxtjs/google-analytics'
in bothbuildModules
andmodules
innuxt.config.js
but didn't work either.both logs are undefined.