Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit e0a92e3

Browse files
refactor: replace timeout with vue nextTick
the nextTick is a better option to avoid registering the previous route see nuxt-community/google-analytics-module#8
1 parent 3239a4a commit e0a92e3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lib/page.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ export function autoTracking () {
9696
return
9797
}
9898

99-
// Add a 0 timeout so that the browser doesn't register the previous route
99+
// Fire tracking after the nextTick or it will still register the previous route
100100
// https://github.com/MatteoGabriele/vue-analytics/issues/44
101-
setTimeout(function () {
101+
config.$vue.nextTick().then(() => {
102102
trackRoute(router.currentRoute)
103-
}, 0)
103+
})
104104
})
105105
}

0 commit comments

Comments
 (0)