Skip to content

Commit

Permalink
feat: push page title to dataLayer (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinzi committed Feb 23, 2020
1 parent d678f16 commit 9434562
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ function gtmServer(ctx, initialized) {

function startPageTracking(ctx) {
ctx.app.router.afterEach((to) => {
setImmediate(() => {
setTimeout(() => {
ctx.$gtm.push(to.gtm || {
routeName: to.name,
pageType: 'PageView',
pageUrl: to.fullPath,
pageUrl: to.fullPath,
pageTitle: document.title,
event: '<%= options.pageViewEventName %>'
})
})
})
}, 250)
})
}

Expand Down

0 comments on commit 9434562

Please sign in to comment.