will try to explain my use case first. Typically when you use google analytics, they will trigger some pageview
event that will be fired everytime the user navigates into the page, as by this definition here
A pageview is defined as a view of a page on your site that is being tracked by the Analytics tracking code. If a user clicks reload after reaching the page, this is counted as an additional pageview. If a user navigates to a different page and then returns to the original page, a second pageview is recorded as well.
I’m trying to manually recreate the second pageview recorded – meaning user navigates to a different page and then returns to the original page, I’m trying to look for a vue/nuxt event that can help me to capture this event. (and also for multiple, meaning pageA -> pageB -> pageA -> pageB -> pageA, page A has 3 pageviews, pageB has 2 pageviews)
mounted
– is only called once on page load, so this can’t be used
updated
– is called everytime dom changes, so this also can’t be used
watch: $route
– seems to be a possible use case, but this event is fired on every route which means I need to always check if the current route matches the original page route where the watcher is (on every navigation) which seems to be really unnecessary work.
Is there any events or lifecycle hooks that I can use for this use case? So i can capture multiple repeated pageviews when a user navigates to and fro pages repeatedly?