NuxtJs - Call Plugin in another plugin - vue-gtag

341 Views Asked by At

I have integrated a Google Analytics component for Nuxt in a plugin :

I'm looking for how to call the $gtag global var instantiate by the gtag component, in another component.

In the target plugin I've tried :

export default ({ app, env, $gtag }) => {
....
}

or :

export default ({ app, env, gtag }) => {
....
}

or :

export default ({ env, app: {gtag} }) => {
....
}

It's always undefined.

Somebody have an idea how to do that ?

gtag-plugin.client.js

import Vue from 'vue'
import VueGtag from 'vue-gtag'

export default ({ app, env }) => {   

  Vue.use(VueGtag, {
    config: { env.gaIdProd },
    bootstrap: getGDPR === 'true',
    appName: 'xxx',
    enabled: getGDPR === 'true',
    pageTrackerScreenviewEnabled: true
  }, app.router)
}
0

There are 0 best solutions below