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";
createApp(App).use(VueGtag, {
config: { id: "GA_MEASUREMENT_ID" },
globalObjectName: 'foo'
From now on the plugin will start using the instance name specified in the options, but you will still be able to use this.$gtag inside your Vue project without any changes.
Copy link