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
- 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.
- Organizations with Advanced Consent Disabled - If your organization does not have Advanced Consent enabled, the Consent Type field will not appear in the child sync configuration—this is expected. However, ensure that Implied consent (opt-in by default) is selected in your pipeline’s Compliance Settings. If Explicit consent is selected instead, all integrations will default to a permanently denied state regardless of Advanced Consent being disabled. With Implied consent selected, the sync functions correctly and all integrations are treated as granted.
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
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 |
| VTC/EVC Support | When ON, keeps gtag.js running on every page load to preserve view-through (VTC) and engaged-view (EVC) attribution. When OFF (default), the tag is suppressed after the initial sync and non-click conversions degrade. Enabling it introduces duplicate-conversion risk that must be configured per destination — review with your CSM first. | No |
| Google Tag Gateway Mode | When ON, each configured tag ID loads gtag.js from a first-party URL on your own domain (CDN reverse-proxied to Google) instead of googletagmanager.com, improving ad-blocker resilience and giving tag cookies a first-party origin. Requires a distinct first-party path per tag ID, configured per destination. Governs script serving only. | No |
| Enhanced Google Consent Signal Mapping | When ON, maps each of Google's four consent signals (ad_storage, ad_user_data, ad_personalization, analytics_storage) to its own consent category or a fixed value (Always granted / Always denied / Not set), instead of inheriting one value for all four. Shapes signals on calls that fire; does not replace the per-sync consent gate. | No |
*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.
GA4 Multi-Destination Support
The destinations array on the GA4 sync sends mapped events to additional GA4 properties beyond the parent property. Each entry accepts a tagID, an optional gtgScriptSource, and an optional reSyncUrl.
[
{
"tagID": "G-XXXXXXX",
"gtgScriptSource": "https://www.example.com/metrics-5/",
"reSyncUrl": "https://www.example.com/metrics-5/g/collect"
}
]Each destination is configured with send_page_view: false, so the configuration call itself does not generate page views in the secondary property. Each destination also receives its own ReSync beacon.
The destinations array itself does not require Google Tag Gateway Mode — destination properties are configured and receive beacons either way. Only the two optional URL fields require it: with Gateway Mode off they are removed from the built configuration, the sync-level ReSync URL field is hidden in the UI, and beacons go to analytics.google.com/g/collect. Only GA4 tag IDs belong in this array — Google Ads and CM360 IDs have their own typed configuration in their respective syncs.
For reSyncUrl, the value becomes the literal beacon path, so a trailing slash is significant — /g/collect and /g/collect/ are different endpoints.
How It Behaves
- ReSync beacons do not fire on every page load. They fire only when the stored session marker has expired and a Google Analytics cookie already exists. On a first visit to a newly configured destination you should expect zero beacons — that is normal, not a misconfiguration.
- No beacon is sent without a stored client ID. If the client ID could not be retrieved — the tag was blocked, or the page was slow on a cold first visit — every destination beacon for that page is skipped silently, with nothing logged.
- Tag IDs must be unique, and this is enforced at build time. A destination tag ID cannot duplicate the parent tag ID, the GA4 sync's own tag ID, or another destination. The build fails validation rather than firing two identical beacons for the same property. Comparison is exact and case-sensitive, so tag IDs must match Google's casing.
- Non-GA4 tag IDs are rejected at build time. Only
G-andGT-prefixes are accepted; anAW-orDC-value fails validation rather than being silently dropped. - Enrichment fields reflect the parent property only. Destination
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 (typicallyC0002 - 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 2 days ago