/** * gtag.js loader. * * Loads `gtag/js?id=` from the vTilt gateway (`/gt`) so that every * subsequent measurement request — `gtag/js`, `/g/collect`, and * `/pagead/conversion` — stays on the first-party origin. Installs the * standard `window.dataLayer` queue and `window.gtag` shim exactly the way * Google's official snippet does, so any third-party integration that * expects them (Ads editor, Tag Assistant, CMP libraries) keeps working. */ import type { GoogleTagClientConfig } from "../../types"; import type { GtagFn } from "./consent-bridge"; export interface GtagLoaderOptions { /** Origin to load gtag.js from. Must include protocol. */ origin: string; /** Path under `origin` that hosts the gateway. Defaults to `/gt`. */ gatewayPath: string; /** Primary tag id used in the loader URL (first `G-*`, else first id). */ primaryTagId: string; /** All tag ids to `gtag('config', id, ...)` after load. */ tagIds: string[]; /** Extra per-tag config. Currently only used to set `server_container_url`. */ configParams?: Record; /** Whether gtag.js should send its own `page_view` when configured. */ sendPageView?: boolean; /** Enable `debug_mode` on gtag configs. */ debugMode?: boolean; /** Enable `conversion_linker` (default true in gtag.js). */ conversionLinker?: boolean; /** Domains for the `linker` feature (cross-domain). */ linkerDomains?: string[]; } export interface LoadedGtag { gtag: GtagFn; dataLayer: unknown[]; } /** * Ensure a single `window.dataLayer` + `window.gtag` pair exists. Safe to * call multiple times — returns the same references. Matches Google's * reference snippet: * * window.dataLayer = window.dataLayer || []; * function gtag(){ dataLayer.push(arguments); } */ export declare function ensureDataLayer(): LoadedGtag; /** * Inject the gtag.js