Skip to main content

Integrations

Google Analytics 4

Wire Google Analytics 4 into every docs page — add your measurement id to `integrations.ga4` and the script loads on next deploy.

Google's current (2023+) analytics product — replaced Universal Analytics. Tracks pageviews, events, and conversions with a free quota suitable for most docs sites.

Configure

integrations.ga4stringpathrequired

Google Analytics 4 Measurement ID. Script injects via <Script strategy="afterInteractive"> and loads from https://www.googletagmanager.com.

{
  "integrations": {
    "ga4": "G-XXXXXXXXXX"
  }
}

Where to find your measurement id

Google Analytics admin → Data Streams → pick your web stream → Measurement ID (format G-XXXXXXXXXX).

Or set it from the dashboard — Editor → Configurations → AI & Advanced → Integrations.

Gotchas

  • Must create the property as Google Analytics 4 (not Universal Analytics). UA properties use a different ID format (UA-…) and are no longer supported.

  • Allow googletagmanager.com in your CSP script-src and www.google-analytics.com in connect-src.

Loading behavior

  • Strategy: afterInteractive — injected after page interactivity, so it never blocks first paint.

  • CSP: if you enforce a Content Security Policy, allowlist https://www.googletagmanager.com in script-src.

  • Removal: delete the integrations.ga4 key (or blank it in the dashboard) and redeploy — the script disappears on the next page load.

Related

Was this page helpful?

Last updated August 7, 2026