GA4 Sync (Decoupled)

What is Google Analytics 4 Sync?

The Google Analytics 4 (GA4) sync retrieves and stores key identifiers required for GA4 tracking and measurement. It captures the GA4 client ID, session information, and Google click identifiers (gclid, dclid, wbraid) that enable proper user tracking and attribution across your GA4 implementation.


Considerations

  • Single GA4 Property - This sync supports one GA4 Measurement ID only. Multi-destination support was removed after an audit found that multiple GA4 destinations were frequently misconfigured. If you need to send data to multiple GA4 properties, deploy separate GA4 syncs.
  • GA4 Tag ID Placement - The GA4 Measurement ID can be specified either in the parent Google Tag Settings (GTAG.js Tag ID) or in the child GA4 sync (Google Analytics 4 Tag ID field). It must be present in one of the two places — if specified in both, the child sync value takes precedence.
  • Cookie Lifetime and Session Alignment - GCLID, DCLID, and WBRAID cookie lifetimes should be set to match the attribution windows configured in your Google Ads and CM360/DV360 accounts. The session timeout controls how long inactivity is allowed before a new session is created — misalignment between this value and GA4's native session timeout can produce inflated session counts.
  • IAB TCF Consent - Enabling IAB TCF Consent requires an IAB TCF v2.0-compliant CMP with the __tcfapi JavaScript API exposed on the site, and Consent Policy set to "Explicit Consent" in MetaRouter Advanced Settings.
  • CMP Compatibility - This sync works with any CMP provided the consent categories are configured correctly in the MetaRouter UI.

Architecture Overview

  • Google Tag Settings serves as the parent and controls gtag.js library loading
  • Google Analytics 4 is a child sync with its own configuration
  • GA4, Google Ads, and CM360 can be configured as separate syncs under the same parent
  • The parent gtag must be deployed before GA4 sync can function
Google Tag Settings (Parent)
├── GTAG.js Tag ID
├── Load GTAG library
├── Load GTAG when zero consent granted
│
└── Syncs (Children)
    ├── Google Analytics 4
    ├── Google Campaign Manager 360 (optional)
    └── Google Ads (optional)

Prerequisites

Before configuring the GA4 sync:

  1. Parent Google Tag Settings must be configured — The parent controls gtag.js library loading and must be deployed first
  2. GA4 property must be set up — You need your Measurement ID (G-XXXXXXXXX) from your GA4 Data Stream

Configuration Fields

Parent Fields (Google Tag Settings)

FieldDescriptionRequired
GTAG.js Tag IDYour Google Analytics 4 Measurement ID (e.g., G-XXXXXXXXX) or Google Ads ID (e.g., AW-XXXXXXXXX). Controls which Google property receives data.No*
Load GTAG libraryToggle to load the gtag.js library. Must be ON for GA4 sync to function.Yes
Load GTAG when zero consent grantedWhen ON, loads gtag even when no consent categories are granted. Useful for consent mode implementations.Yes

*GTAG.js Tag ID is optional in the parent if specified in the child GA4 sync.


GA4 Sync Fields (Google Analytics 4)

FieldDescriptionRequiredDefault
Consent TypeConsent category required before sync fires (e.g., C0002 - Performance). Must be created in Settings > Consent Settings first.Yes
IAB TCF ConsentEnable IAB Transparency & Consent Framework integration. Requires Consent Policy set to "Explicit Consent" in Advanced Settings.NoDisabled
Session TimeoutSession timeout in minutes. Controls when a new session is created after inactivity.No30
Google Analytics 4 Tag IDYour GA4 Measurement ID (e.g., G-XXXXXXXXX). Can be specified here or in parent.Yes*
GCLID Cookie Lifetime (in days)Expiration for Google Click ID cookie.No90
DCLID Cookie Lifetime (in days)Expiration for Display Click ID cookie.No90
WBRAID Cookie Lifetime (in days)Expiration for WBRAID (iOS web-to-app) cookie.No90

*Required if not specified in parent Google Tag Settings.

Note — Single GA4 Property: This sync supports one GA4 Measurement ID only. Multi-destination support was removed after an audit found that multiple GA4 destinations were frequently misconfigured. If you need to send data to multiple GA4 properties, deploy separate GA4 syncs.


Setup

1. Configure Parent Google Tag Settings

  1. From the Pipelines page, find the pipeline associated with your web property
  2. Hover over the three-dot dropdown and select "Build AJS File"
  3. In the Identity Syncs section, add Google Tag Settings
  4. Configure the parent fields:
    • GTAG.js Tag ID: Enter your GA4 Measurement ID (e.g., G-VL2DEQTEXZ) or leave blank if specified in child sync
    • Load GTAG library: Set to ON
    • Load GTAG when zero consent granted: Set based on your consent requirements

2. Add GA4 Sync

  1. Under the Syncs section within Google Tag Settings, add Google Analytics 4
  2. Configure the sync fields:
  • Consent Type Select the consent category required before the sync fires (typically C0002 - Performance for analytics).
  • IAB TCF Consent Enable if using IAB TCF v2.0-compliant CMP. Prerequisites:
    • Consent Policy must be set to "Explicit Consent" in Advanced Settings
    • IAB TCF v2.0-compliant CMP must be installed on your site
    • CMP must expose the __tcfapi JavaScript API
  • Session Timeout Set the session timeout in minutes (default: 30). A new session is created after this period of inactivity.
  • Google Analytics 4 Tag ID Enter your GA4 Measurement ID if not specified in the parent (e.g., G-XXXXXXXXX).
  • Cookie Lifetimes Adjust GCLID, DCLID, and WBRAID cookie lifetimes as needed (default: 90 days each).

3. Save and Deploy

  1. Click Save and Build File
  2. Deploy your AJS file to propagate changes to your web property

Technical Details

Sync Behavior

The sync executes the following steps:

  1. Checks gtag.js availability (must be loaded by parent Google Tag configuration)
  2. Retrieves or creates GA4 client ID from existing _ga cookie or generates new one
  3. Captures attribution IDs (gclid, dclid, wbraid) from URL parameters
  4. Creates/retrieves session information (session ID and session count)
  5. Fires MetaRouterSync event via gtag('event', 'MetaRouterSync', {})
  6. Stores markers for client ID, session ID, and session count

Storage Markers

Storage TypeKeyTTL
Cookie/IndexedDB[prefix]_googleAnalytics4_ga4_client_id45 days
Cookie/IndexedDB[prefix]_googleAnalytics4_ga4_session_idsessionTimeOutInMinutes (configurable)
Cookie/IndexedDB[prefix]_googleAnalytics4_ga4_session_count45 days

Sync Response Example

When the sync executes successfully, it returns:

{
  "clientID": "1234567890.1234567890",
  "sessionID": "1595262825000",
  "sessionCount": 3
}

Server-Side Enrichment

Adds to context.providers.googleAnalytics4:

{
  "googleAnalytics4": {
    "clientID": "1234567890.1234567890",
    "sessionID": "1595262825000",
    "sessionCount": 2
  }
}

Verification

  1. Check Browser Developer Tools:
    • Open Network tab and filter for google-analytics.com
    • Look for MetaRouterSync event requests
    • Verify client_id parameter is present
  2. Check Cookies/Storage:
    • Look for _ga cookie (GA4 client ID)
    • Look for [prefix]_googleAnalytics4_ga4_client_id marker
    • Verify session markers are present
  3. Check GA4 Dashboard:
    • Navigate to GA4 > Realtime reports
    • Verify events are appearing with correct client IDs
  4. Server-side Event Validation:
    • Use MetaRouter's event debugger
    • Verify context.providers.googleAnalytics4 is present with clientID, sessionID, sessionCount