Page tracker
If you are using VueRouter inside your application, you can simply pass your router instance, and the plugin will start tracking all your pages automatically
import { configure } from "vue-gtag";
import router from './router'
configure({
tagId: "GA_MEASUREMENT_ID",
pageTracker: {
router,
}
})
By default, the tracking system uses pageviews with the following template.
{
page_path: '/', // route path value
page_location: 'http://localhost:8080/' // window.location.href
}Enable screen_view
Now, it will use screen_view events for tracking instead of the default page
Page tracker template
The automatic tracker system can use a custom template, instead of the default one: this will apply whether you are using pageviews or screenviews.
Exclude routes
pass routes path or routes name that you want to exclude from the automatic tracking
You can also provide a custom function that returns a boolean value.
Route path types
Use route full path
Prepend router base path
Last updated