Access gtag instance directly

The plugin provides a list of methods that help you write less code. For example, the "customMap" method

import { customMap } from 'vue-gtag'

customMap({ key: 'value' })    

This internally will fire the following

window.gtag('config', 'GA_MEASUREMENT_ID', {
   custom_map: { key: 'value' }
})

The gtag.js library includes numerous events and configurations. In cases not covered, it is possible to use the "query" method that provides access to the gtag instance.

import { query } from 'vue-gtag'

query('config', 'GA_MEASUREMENT_ID', {
   custom_map: { key: 'value' }
})  

Last updated