For the complete documentation index, see llms.txt. This page is also available as Markdown.

Plugin hooks

Plugin bootstrapped

Will fire when the gtag script is successfully loaded

import Vue from "vue";
import VueGtag from "vue-gtag";

Vue.use(VueGtag, {
  config: { id: "UA-1234567-1" },
  onReady () {
    // ready
  }
});

Before and after tracking

The auto tracking feature of vue-gtag will fire a pageview or screenview after each route change and it is possible to add a hook right before and/or right after the page is tracked.

import Vue from "vue";
import VueGtag from "vue-gtag";

Vue.use(VueGtag, {
  config: { id: "UA-1234567-1" },
  onBeforeTrack () {
    // before!
  },
  onAfterTrack () {
    // after!
  }
});

Last updated