Plugin options
/**
* Complete configuration object with all available options
*/
createGtag({
/**
* Primary Google Tag Manager or Google Analytics tag ID.
*/
tagId: 'G-XXXXXXXX',
/**
* Configuration settings for the main `tagId`.
*/
config: undefined,
/**
* Additional tag IDs and their configurations to be tracked alongside the main `tagId`.
*/
additionalAccounts: undefined,
/**
* Configuration for loading the gtag.js script.
*/
resource: {
/**
* URL of the gtag.js script.
* @default "https://www.googletagmanager.com/gtag/js"
*/
url: 'https://www.googletagmanager.com/gtag/js',
/**
* Enable preconnecting to the script's domain for faster loading.
* @default false
*/
preconnect: false,
/**
* Load the script with the `defer` attribute.
* @default false
*/
defer: false,
/**
* A nonce value for the script tag, useful for enforcing Content Security Policy (CSP).
*/
nonce: undefined
},
/**
* Custom global variable name for the data layer.
* @default "dataLayer"
*/
dataLayerName: 'dataLayer',
/**
* Custom global function name for `gtag`.
* @default "gtag"
*/
gtagName: 'gtag',
/**
* Custom analytics group name.
* @default "default"
*/
groupName: 'default',
/**
* Settings for automatic route tracking.
* Make sure to disable pageview tracking from the "Enhanced measurement" in your Data Stream to avoid
* possible double-tracking of your routes.
*/
pageTracker: {
/**
* Vue Router instance used for tracking navigation events.
*/
router: undefined,
/**
* Custom template for generating route tracking events.
*/
template: undefined,
/**
* Use `screen_view` instead of the default `page_view` event.
* @default false
*/
useScreenview: false,
/**
* Set `send_page_view` for each route change.
* @default true
*/
sendPageView: true,
/**
* Use the router base path option
*/
useRouterBasePath: false,
/**
* Sets the `page_path` equal to the route `fullPath` instead of `path` property
*/
useRouteFullPath: false,
/**
* Defines routes to exclude from tracking.
* - Can be an array of route objects identified by `path` or `name`.
* - Can also be a function that returns `true` to exclude the route from tracking.
*/
exclude: undefined
},
/**
* Configuration for cross-domain tracking.
*/
linker: undefined,
/**
* Collection of lifecycle hooks and event callbacks for tracking and configuration.
*/
hooks: {
/**
* Triggered before a route tracking event is fired.
* @param route - The current route being tracked.
*/
'router:track:before': undefined,
/**
* Triggered after a route tracking event is fired.
* @param route - The current route that was tracked.
*/
'router:track:after': undefined,
/**
* Triggered before the initial configuration request is sent.
*/
'config:init:before': undefined,
/**
* Triggered after the initial configuration request is sent.
*/
'config:init:after': undefined,
/**
* Called when the gtag.js script successfully loads.
*/
'script:loaded': undefined,
/**
* Called when the gtag.js script fails to load.
* @param error - The error encountered during script loading.
*/
'script:error': undefined
},
/**
* Default consent mode applied during initialization.
*/
consentMode: undefined,
/**
* Whether to initialize the Google tag script immediately after the page has loaded.
*
* @remarks
* - Set this to `manual` to delay the initialization until you call the `addGtag` function manually.
* - Set this to `manual` if you want to use the `useConsent` composable.
*
* @default 'auto'
*/
initMode: 'auto',
/**
* Default value for `app_name` when using the `screen_view` tracking method.
*/
appName: undefined
})
Last updated