vue-gtag
Github
v2
v2
  • Get started
  • Migration v1 to v2
  • 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

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'
}).mount("#app");

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.

PreviousOpt-in/outNextAccess gtag instance directly

Last updated 4 years ago