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
  }
});

This method will not be triggered if you have disabled the script loading

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