vue-gtag
Github
v1
v1
  • Get started
  • Bootstrap options
  • Auto tracking
  • Multiple domain tracking
  • Plugin hooks
  • API
  • Opt-in/out
  • Global namespace
  • Access gtag instance directly
  • Debug
  • Plugin options
  • Methods
    • pageview
    • event
    • screenview
    • customMap
    • purchase
    • linker
    • set
    • time
    • config
    • exception
Powered by GitBook
On this page
  • Plugin bootstrapped
  • Before and after tracking

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!
  }
});
PreviousMultiple domain trackingNextAPI

Last updated 5 years ago