# Plugin hooks

## Plugin bootstrapped

Will fire when the gtag script is successfully loaded

```javascript
import { createApp } from "vue";
import App from "./App.vue";
import VueGtag from "vue-gtag";

createApp(App).use(VueGtag, {
  config: { id: "GA_MEASUREMENT_ID" },
  onReady () {
    // ready
  }
}).mount("#app");
```

{% hint style="warning" %}
This method will not be triggered if you have disabled the script loading
{% endhint %}

## Before and after tracking&#x20;

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.

```javascript
import { createApp } from "vue";
import { createRouter } from 'vue-router'
import App from "./App.vue";
import VueGtag from "vue-gtag";

const router = createRouter(...)

createApp(App).use(VueGtag, {
  config: { id: "GA_MEASUREMENT_ID" },
  onBeforeTrack () {
    // before!
  },
  onAfterTrack () {
    // after!
  }
}, router).mount("#app");
```
