nuxt-community / google-gtag-module

Enable google gtagjs for NuxtJs
MIT License
145 stars 29 forks source link

this.$metaInfo not available in layout.vue #21

Open sebastianjung opened 4 years ago

sebastianjung commented 4 years ago

According to this: https://github.com/nuxt-community/google-gtag#to-make-sure-that-every-page-is-tracked-correctly

one can put the mounted() Code inside of the layout.vue file which does not work because the layout file has no this.$metaInfo information accessible.

If i am right the readme should be changed from

// make sure to set disableAutoPageTrack: true inside of nuxt.config.js
// inside of your Page.vue/Layout.vue file

to

// make sure to set disableAutoPageTrack: true inside of nuxt.config.js
// inside of your Page.vue files

BTW: Is there any way to globally import that code as a mixin into all page components only? (Not all components globally)

vibonacci commented 4 years ago

I'm facing the same issue. For now I will be using the disableAutoPageTrack to false method

rkJun commented 4 years ago

To track all pages, I need to put tracking code on every page. Is there any other way?

jamiecarter7 commented 3 years ago

Bump ^^