Bootstrap options
Choose how you want to initialise vue-gtag in your application
By default, the plugin will create a gtag instance of the library in the window scope and download the library for you, but often users have different use cases, so here we will take a look at them.
Disable script loading
Bootstrap later
It is possible to set up the entire plugin options but to bootstrap it later on whenever the user decides to. This could also be useful for any GDPR proof projects.
Later on, in any places of your application, in any moment, you can simply import the bootstrap method in your code and run it
the bootstrap method will return a promise that will be resolved when the script has been loaded completely.
The bootstrap promise returns the actual gtag api object, which is not what it's injected inside the Vuejs scope by the plugin, but the pure and simple gtag library.
To start using vue-gtag after bootstrap successful response, you can simply access the library from the component scope.
Set options
Normally you would add all your options inside the global object when installing the plugin, but it is also possible to set those options later in conjunction with calling the bootstrap method.
Start always but setting the bootstrap option to false
then just go to a component in another place in your code and type something like this
Make sure to set your options before calling the bootstrap method or your new options won't be saved
Last updated