> For the complete documentation index, see [llms.txt](https://matteo-gabriele.gitbook.io/vue-gtag/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://matteo-gabriele.gitbook.io/vue-gtag/master/plugin-hooks.md).

# Plugin hooks

## Plugin bootstrapped

Will fire when the gtag script is successfully loaded

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

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

{% 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 Vue from "vue";
import VueGtag from "vue-gtag";

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