Created
April 14, 2020 13:58
-
-
Save voltane/d1ca4efadef7f7c7bfd65e3f18039a66 to your computer and use it in GitHub Desktop.
GTM for Nuxt - PageView problem proposal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createMixin = (): VueConstructor | ComponentOptions<Vue> => ({ | |
beforeRouteEnter: (to: Route, from: Route, next: Function) => { | |
next((vm: Vue) => { | |
setTimeout(() => { | |
// Enter Your code which send event to GTM | |
// @ts-ignore | |
window[this.options.layer].push(to.gtm || { | |
event: this.options.pageViewEventName, | |
pageType: 'PageView', | |
pageUrl: to.fullPath, | |
pageTitle: document.title, | |
routeName: to.name, | |
}) | |
}, 0) | |
}) | |
}, | |
}) | |
Vue.mixin(createMixin()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment