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
__tcfapiJavaScript 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:
- Parent Google Tag Settings must be configured — The parent controls gtag.js library loading and must be deployed first
- 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)
| Field | Description | Required |
|---|---|---|
| GTAG.js Tag ID | Your 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 library | Toggle to load the gtag.js library. Must be ON for GA4 sync to function. | Yes |
| Load GTAG when zero consent granted | When 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)
| Field | Description | Required | Default |
|---|---|---|---|
| Consent Type | Consent category required before sync fires (e.g., C0002 - Performance). Must be created in Settings > Consent Settings first. | Yes | — |
| IAB TCF Consent | Enable IAB Transparency & Consent Framework integration. Requires Consent Policy set to "Explicit Consent" in Advanced Settings. | No | Disabled |
| Session Timeout | Session timeout in minutes. Controls when a new session is created after inactivity. | No | 30 |
| Google Analytics 4 Tag ID | Your 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. | No | 90 |
| DCLID Cookie Lifetime (in days) | Expiration for Display Click ID cookie. | No | 90 |
| WBRAID Cookie Lifetime (in days) | Expiration for WBRAID (iOS web-to-app) cookie. | No | 90 |
*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
- From the Pipelines page, find the pipeline associated with your web property
- Hover over the three-dot dropdown and select "Build AJS File"
- In the Identity Syncs section, add Google Tag Settings
- 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
- GTAG.js Tag ID: Enter your GA4 Measurement ID (e.g.,
2. Add GA4 Sync
- Under the Syncs section within Google Tag Settings, add Google Analytics 4
- Configure the sync fields:
- Consent Type
Select the consent category required before the sync fires (typically
C0002 - Performancefor 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
__tcfapiJavaScript 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
- Click Save and Build File
- Deploy your AJS file to propagate changes to your web property
Technical Details
Sync Behavior
The sync executes the following steps:
- Checks gtag.js availability (must be loaded by parent Google Tag configuration)
- Retrieves or creates GA4 client ID from existing
_gacookie or generates new one - Captures attribution IDs (
gclid,dclid,wbraid) from URL parameters - Creates/retrieves session information (session ID and session count)
- Fires MetaRouterSync event via
gtag('event', 'MetaRouterSync', {}) - Stores markers for client ID, session ID, and session count
Storage Markers
| Storage Type | Key | TTL |
|---|---|---|
| Cookie/IndexedDB | [prefix]_googleAnalytics4_ga4_client_id | 45 days |
| Cookie/IndexedDB | [prefix]_googleAnalytics4_ga4_session_id | sessionTimeOutInMinutes (configurable) |
| Cookie/IndexedDB | [prefix]_googleAnalytics4_ga4_session_count | 45 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
- Check Browser Developer Tools:
- Open Network tab and filter for
google-analytics.com - Look for
MetaRouterSyncevent requests - Verify client_id parameter is present
- Open Network tab and filter for
- Check Cookies/Storage:
- Look for
_gacookie (GA4 client ID) - Look for
[prefix]_googleAnalytics4_ga4_client_idmarker - Verify session markers are present
- Look for
- Check GA4 Dashboard:
- Navigate to GA4 > Realtime reports
- Verify events are appearing with correct client IDs
- Server-side Event Validation:
- Use MetaRouter's event debugger
- Verify
context.providers.googleAnalytics4is present with clientID, sessionID, sessionCount
Updated about 15 hours ago