Global namespace

With gtag.js it's possible to customize the name of your global gtag instance to avoid conflicting with already installed library instances in your application.

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

const app = createApp(App);

app.use(VueGtag, {
  property: {
    id: "GA_MEASUREMENT_ID"
  },
  globalObjectName: 'foo'
});

app.mount("#app");

From now on the plugin will start using the instance name specified in the options, but this will not change the way you will access the gtag methods using the options API: this.$gtag will still be valid.

This property can only be changed in the plugin install because the global namespace will only be assigned once.

Last updated