![]()
This SharePoint Framework (SPFx) Application Customizer injects Google Tag Manager (GTM) into SharePoint Modern pages, enabling analytics and tag management across your tenant. It initializes the standard GTM dataLayer, loads the GTM script via SPComponentLoader, and hooks into SharePoint’s navigation events to track Single Page Application (SPA) route changes — ensuring every page view is captured without a full browser reload.
Open this sample in the gallery (popup panel): Open in gallery
Source: https://github.com/pnp/sp-dev-fx-extensions/tree/main/samples/js-application-gtm-injector