The plugin offers hooks for nearly all aspects of its life cycle.
export type Hooks = {
/**
* Triggered before a route tracking event is fired.
* @param route - The current route being tracked.
*/
"router:track:before"?: (route: Route) => void;
/**
* Triggered after a route tracking event is fired.
* @param route - The current route that was tracked.
*/
"router:track:after"?: (route: Route) => void;
/**
* Triggered before the initial configuration request is sent.
*/
"config:init:before"?: () => void;
/**
* Triggered after the initial configuration request is sent.
*/
"config:init:after"?: () => void;
/**
* Called when the gtag.js script successfully loads.
*/
"script:loaded"?: () => void;
/**
* Called when the gtag.js script fails to load.
* @param error - The error encountered during script loading.
*/
"script:error"?: (error: unknown) => void;
};
For example, you want to set some events before the first configuration hit