-
Notifications
You must be signed in to change notification settings - Fork 73
Description
In our app we have router redirect to sign in page if user's auth token has expired. If we want additionally track UTM parameters (utm_source, utm_medium, etc), we pass it in the URL. For example:
/dashboard?utm_source=push&utm_medium=welcome
If a user is signed in, the VueGtag takes this URL with utm_* params and tracks them correctly.
If a user is not signed in and we redirect it immediately to /sign-up, and it tracks the latter URL. Probably to the race condition.
Of course possible solutions are:
- Pass utm_* params to redirected URL. However there is not the only such case and dragging querystring through all redirects is a bit ugly in a large app.
- Wait for the tracking event to happen and redirect then. We tried:
Vue.use(VueGtag, {
config: { id: "..." },
onAfterTrack () {
redirectNow()
}
}, router)
But for some reason onAfterTrack() is never called (vue-gtag version 1.16.1). Moreover it's not clear if it is called always. For example when adblocker is active, or what if there is a network latency or Analytics service down.
If there any recommendation how to handle such race conditions in a best way or do we miss something?