/** * Matomo Tag Manager (MTM) integration. * * Loads a Matomo Tag Manager container and exposes a typed helper to push * entries to the `_mtm` data layer. Works with both the App Router and the * Pages Router, and integrates with the server-side proxy * (`withMatomoProxy()`) so the container script can be served from your own * domain. * * @module tag-manager */ /** An entry pushed to the Matomo Tag Manager `_mtm` data layer */ export type TagManagerDataLayerEntry = Record; declare global { interface Window { /** Matomo Tag Manager data layer */ _mtm?: TagManagerDataLayerEntry[]; } } /** Options for {@link initTagManager} */ export interface TagManagerSettings { /** * Matomo base URL (e.g. "https://analytics.example.com"). * * When using the server-side proxy (`withMatomoProxy()`), you can omit this * and the library will automatically load the container through * `NEXT_PUBLIC_MATOMO_PROXY_PATH` (so the browser only talks to your own * domain). */ url?: string; /** * Container ID, as shown in Matomo → Tag Manager → your container * (e.g. "aBcDeF12"). The container script is loaded from * `{url}/js/container_{containerId}.js`. */ containerId?: string; /** * Full container script URL. Takes precedence over `url` + `containerId`. * * Useful for non-live container environments, whose file names carry an * extra suffix (e.g. `container_aBcDeF12_staging_….js`). */ containerUrl?: string; /** * When `true` (default), and if `NEXT_PUBLIC_MATOMO_PROXY_PATH` is defined, * the container is loaded through the server-side proxy instead of the * provided `url`. * * @default true */ useProxy?: boolean; /** CSP nonce added to the injected `