Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/plugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { log } from './gtm.utils'
import Vue from 'vue'

const _layer = '<%= options.layer %>'
const _id = '<%= options.id %>'
Expand Down Expand Up @@ -65,15 +66,15 @@ function gtmServer(ctx, initialized) {

function startPageTracking(ctx) {
ctx.app.router.afterEach((to) => {
setTimeout(() => {
Vue.nextTick().then(() => {
ctx.$gtm.push(to.gtm || {
routeName: to.name,
pageType: 'PageView',
pageUrl: '<%= options.routerBase %>' + to.fullPath,
pageTitle: (typeof document !== 'undefined' && document.title) || '',
event: '<%= options.pageViewEventName %>'
})
}, 250)
})
})
}

Expand Down
5 changes: 3 additions & 2 deletions lib/plugin.mock.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
// This is a mock version because gtm module is disabled
// You can explicitly enable module using `gtm.enabled: true` in nuxt.config
import { log } from './gtm.utils'
import Vue from 'vue'

const _layer = '<%= options.layer %>'
const _id = '<%= options.id %>'

function startPageTracking (ctx) {
ctx.app.router.afterEach((to) => {
setTimeout(() => {
Vue.nextTick().then(() => {
ctx.$gtm.push(to.gtm || {
routeName: to.name,
pageType: 'PageView',
pageUrl: '<%= options.routerBase %>' + to.fullPath,
pageTitle: (typeof document !== 'undefined' && document.title) || '',
event: '<%= options.pageViewEventName %>'
})
}, 250)
})
})
}

Expand Down