google-gtag-module icon indicating copy to clipboard operation
google-gtag-module copied to clipboard

this.$metaInfo not available in layout.vue

Open sebastianjung opened this issue 5 years ago • 3 comments

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)

sebastianjung avatar Nov 13 '19 09:11 sebastianjung

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

vibonacci avatar Jan 04 '20 15:01 vibonacci

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

rkJun avatar Apr 02 '20 07:04 rkJun

Bump ^^

jamiecarter7 avatar Nov 10 '20 16:11 jamiecarter7