Skip to content
Last updated

Google Tag Manager analytics

Integrate Google Tag Manager into Redocly project.

With the consent option on, this integration loads only while the consent state allows the analytics category. In opt-in mode the visitor must accept first. In opt-out mode the category starts on and stays on until the visitor refuses.

Configuration

OptionTypeDescription
includeInDevelopmentbooleanSet this option to true to enable GTM Analytics in development mode and preview builds. Default: false.
trackingIdstringREQUIREDGTM tracking ID
gtmAuthstringGTM environment auth string
gtmPreviewstringGTM environment preview name
defaultDataLayerobjectAn arbitrary data layer object. Redocly sets it before GTM loads.
dataLayerNamestringName of GTM datalayer
enableWebVitalsTrackingbooleanEnable web vitals tracking
selfHostedOriginstringSet this for custom GTM server hosting
pageViewEventNameStringSet this option to change the event name for page views. Default: pageView.

Example

analytics:
  gtm:
    includeInDevelopment: true
    trackingId: my-tracking-id
    gtmAuth: my-gtm-auth-string
    gtmPreview: my-gtm-preview-name
    defaultDataLayer:
      platform: redocly
    dataLayerName: my-data-layer-name
    enableWebVitalsTracking: true
    selfHostedOrigin: http://my-gtm-server-host.com
    pageViewEventName: routeChange

Resources