Google Analytics 4 - Collect
What Is Google Analytics 4 - Collect?
Google Analytics 4, commonly referred to as GA4, is the latest iteration of Google's web analytics platform, designed to provide deeper insights into user behavior across websites and apps. It offers a more holistic approach to analytics by integrating data from various touchpoints, including websites, mobile apps, and other digital platforms. GA4 focuses on user-centric measurement, emphasizing the importance of understanding individual user journeys and interactions.
Product Type: Analytics
Integration Type: Starter Kit & ID Sync
Event Source Type: Web and Mobile Browser
Event Scope: Full-funnel Events
GA4 Measurement Protocol vs Collect Endpoint
MetaRouter has two integrations for GA4:
- GA4 - Measurement (Recommended): Uses the Measurement Protocol for server-side tracking with structured JSON data
- GA4 - Collect: Uses the Collect endpoint, mimicking browser-based gtag.js behavior
For more information about Google Analytics 4 - Measurement, please see here.
| Aspect | GA4 Measurement (Recommended) | GA4 Collect |
|---|---|---|
| Endpoint | https://www.google-analytics.com/mp/collect | https://google-analytics.com/g/collect |
| Method | POST | GET |
| Data Format | JSON payload (structured) | URL parameters (flat) |
| Authentication | API_SECRET + MEASUREMENT_ID | MEASUREMENT_ID only |
| Product Data | Structured items array | Encoded strings (pr1, pr2, etc.) |
| Consent Support | Full (ad_user_data, ad_personalization) | Limited |
| Device Object | Full device information | Not available |
| Geolocation | ip_override, user_location (Oct 2024) | Native (_uip) |
| Batch Processing | Events array | Individual events |
| Debug Mode | Via validation endpoint | ep.debug_mode=true |
| Use Case | Server-side tracking, batch processing | Browser-like behavior, simple setup |
| Release Status | Mature (2022), actively enhanced | Newer (2024) |
Choose GA4 Measurement (Recommended) for: Server-side integrations, structured e-commerce data, consent management, batch event processing, mobile apps
Choose GA4 Collect for: Simple setup without API secrets, debugging (URL-visible parameters), scenarios requiring browser-like behavior simulation
Capabilities
- Browser-like event tracking via the GA4 Collect endpoint, mimicking gtag.js behavior.
- Simple setup with no API secret required — only a
MEASUREMENT_IDis needed. - Native geolocation support via
_uip(user IP address). - Multi-property support by configuring multiple destination IDs to route events to multiple GA4 properties simultaneously.
- URL-visible parameters for easy debugging and validation.
Considerations
- GA4 Collect vs Measurement - GA4 Measurement is the recommended server-side integration — structured JSON payload, full consent parameter support, batch processing, and device/geolocation objects. GA4 Collect mimics browser-based gtag.js behavior with simpler setup (no API secret required) but limited feature support. Use Collect when you need browser-like behavior simulation, URL-visible parameters for debugging, or want to avoid managing an API secret.
- Known Limitations - No user engagement reporting (engagement metrics may not be fully available in GA4 reporting), cross-network reporting may not be present in user and traffic acquisition reports, and product information uses encoded strings (
pr1,pr2) rather than structured arrays. - No API Secret Required - Unlike GA4 Measurement, the Collect integration requires only a
MEASUREMENT_ID. No API secret is needed, which simplifies setup but also means there is no server-side authentication on the request. - gclid and dclid Mapping - Unlike GA4 Measurement, the Collect integration maps
gclidanddclidat the event level as URL parameters, reflecting the browser-like behavior of the Collect endpoint. Ensure the Google Gtag sync is configured so these values are available incontext.providers.googleGtag.data. - Multi-Property Support via Destination IDs - Including multiple destination IDs in the Gtag sync instantiates separate gtag configs, routing events to multiple GA4 properties simultaneously. This is useful for multi-region setups or A/B testing across properties. Note that single-property support is the recommended default — only add multiple destinations if explicitly required.
- Custom Dimensions for User Parameters - To surface user parameters (e.g.,
metarouter_anonymousid) in GA4 reporting, they must first be registered as custom dimensions in GA4: navigate to Admin > Data Display > Custom Definitions, create a new dimension with Scope: User, and set the User Property to match the parameter name.
Getting Started - From Your Google Analytics Account
Google Ads Auto-Tagging
Enable Google Ads auto-tagging for Google Ads reporting.
Auto-tagging automatically imports Google Ads data into Analytics. Combining Google Ads data with the rich post-click information provided by Analytics allows you to see what happened on your site after people clicked on your ads. When you enable auto-tagging, a parameter called gclid is added to your landing page URL when a user clicks over to your site from an ad.
Obtain Your Measurement ID
- Log in to your Google Analytics account.
- Navigate to the Admin section.
- In the "Property settings" column, expand "Data collection and modification", click on "Data Streams."
- Here, you'll find a list of data streams associated with the property.
- Click on the data stream for which you want to find the measurement ID.
- The measurement ID is displayed at the top of the page (e.g.,
G-XXXXX00000).
Adding a Google Analytics 4 - Collect Integration
Google Tag Sync (ID Sync Configuration)
To gather the cid, gclid (Google click ID), dclid (Display click ID), session ID, and session count, you must configure a Google Gtag sync. The sync configuration differs based on whether you're using the decoupled or coupled architecture.
| Architecture | Description | Documentation |
|---|---|---|
| GA4 Sync - Decoupled | GA4 as a separate sync under parent Google Tag Settings | Gtag Decoupled: sync GA4 |
| Google Tag Sync - Coupled (Legacy) | GA4 bundled with CM360/Google Ads in single Google Gtag sync | Gtag Coupled: sync GA4 |
Both architectures use the same Google Gtag sync configuration and produce identical results. The sync configuration, parameters, and behavior described in the Google Tag Overview apply to both architectures.
Google Analytics 4 - Collect Starter Kit
From the integration library, add a Google Analytics 4 (Collect) integration. Then, fill out the Connection Parameters:
| Connection Parameter | Description |
|---|---|
MEASUREMENT_ID | The GA4 measurement ID is a unique identifier assigned to each Google Analytics 4 property, allowing data to be collected and associated with that specific property. |
Destination IDs (Multi-Property Support)
Including multiple destination IDs in the array instantiates separate GTAG configs, allowing events to be routed to multiple GA4 properties. This is useful for:
- Customers with multiple EU country-specific GTAGs
- Multi-property setups (e.g., regional properties)
- A/B testing across different GA4 properties
Example configuration:
["G-XXXXXXXXX", "G-YYYYYYYYY", "G-ZZZZZZZZZ"]Add Integration to Pipeline
Once you've adjusted the starter kit:
- Go to Pipelines > Select your Pipeline
- Click the Right drop-down > Add Integration
- Select your Google Analytics 4 - Collect integration and revision > Deploy
Event Mappings
MetaRouter provides all of the event mappings that Google integrations typically require. You may add custom events, parameters or mappings in accordance with Google Analytics 4 Event documentation.
Global Mappings
Global mappings apply to all events. If your parameter names don't match the Expected Inputs, overwrite them with your own.
| Output Key | Description | Expected Input |
|---|---|---|
gclid | String: Google Ad Click ID | Expression - Third segment extracted from GA click ID cookie value |
dclid | String: Google Display Ads ID | Expression - Third segment extracted from Display click ID cookie value |
cid Required | String: Client ID | Expression - Extracted from GA cookie (_ga), falls back to anonymousId |
dl | String: Page URL (document location) | context.page.url |
dt | String: Page title | context.page.title |
dr | String: Page referrer | context.page.referrer |
ua Highly Recommended | String: User agent (required for platform data) | context.userAgent |
_uip Highly Recommended | String: User IP address (required for geolocation) | context.ip |
ci | String: Campaign ID | context.campaign.id |
cs | String: Campaign source | context.campaign.source |
cm | String: Campaign medium | context.campaign.medium |
cn | String: Campaign name | context.campaign.name |
cc | String: Campaign content | context.campaign.content |
ck | String: Campaign term | context.campaign.term |
sid Highly Recommended | String: Session ID (required for session data) | context.providers.googleGtag.data.sessionID |
sct Highly Recommended | Integer: Session count (required for session data) | context.providers.googleGtag.data.sessionCount |
_et Required | Integer: Engagement time in milliseconds | properties.engagement_time_milliseconds (default: 1) |
tid Required | String: Tracking/Measurement ID | Enrichment - MEASUREMENT_ID |
v Required | Integer: Protocol version (must equal 2) | Enrichment - 2 |
isDebugMode | Boolean: Enable debug mode | Enrichment - false (set to true to enable; connection transform converts to ep.debug_mode=true) |
up.metarouter_anonymousid | String: MetaRouter anonymous ID sent as user property | Expression - anonymousId |
Note: To send a user parameter to GA4 (e.g., metarouter_anonymousid), you must first set up user parameters in GA4 as a custom dimension:
- Navigate to Admin > Data Display > Custom Definitions in GA4
- Click Create Custom Dimension
- Name your dimension, set Scope to User, and set User Property to
metarouter_anonymousid
Event Specific
Page
| Output Key | Description | Expected Input |
|---|---|---|
en Required | String: Event name | Enrichment - page_view |
isConversion | Boolean: Mark as conversion | Enrichment - true |
Pro
| Output Key | Description | Expected Input |
|---|---|---|
ep-search_term | String: Search term | properties.query |
en Required | String: Event name | Enrichment - search |
Product List Viewed
| Output Key | Description | Expected Input |
|---|---|---|
ep-item_list_id | String: List ID | properties.list_id |
ep-item_list_name | String: List name | properties.category |
pr1, pr2... | String: Product information (encoded) | Expression - Products array encoded as indexed key-value pairs |
en Required | String: Event name | Enrichment - view_item_list |
Product Clicked
| Output Key | Description | Expected Input |
|---|---|---|
pr1 | String: Product information (encoded) | Expression - Single product encoded as key-value pairs |
en Required | String: Event name | Enrichment - select_item |
Product Viewed
| Output Key | Description | Expected Input |
|---|---|---|
cu | String: Currency (ISO 4217) | properties.currency (default: USD) |
epn-value | Number: Monetary value | Expression - properties.value, falls back to price × quantity |
pr1 | String: Product information (encoded) | Expression - Single product encoded as key-value pairs |
en Required | String: Event name | Enrichment - view_item |
Product Added
| Output Key | Description | Expected Input |
|---|---|---|
cu | String: Currency (ISO 4217) | properties.currency (default: USD) |
epn-value | Number: Monetary value | Expression - properties.value, falls back to price × quantity |
pr1 | String: Product information (encoded) | Expression - Single product encoded as key-value pairs |
isConversion | Boolean: Mark as conversion | Enrichment - true |
en Required | String: Event name | Enrichment - add_to_cart |
Product Removed
| Output Key | Description | Expected Input |
|---|---|---|
cu | String: Currency (ISO 4217) | properties.currency (default: USD) |
epn-value | Number: Monetary value | Expression - properties.value, falls back to price × quantity |
pr1 | String: Product information (encoded) | Expression - Single product encoded as key-value pairs |
en Required | String: Event name | Enrichment - remove_from_cart |
Cart Viewed
| Output Key | Description | Expected Input |
|---|---|---|
cu | String: Currency (ISO 4217) | properties.currency (default: USD) |
epn-value | Number: Monetary value | Expression - Sum of price × quantity across all products |
pr1, pr2... | String: Product information (encoded) | Expression - Products array encoded as indexed key-value pairs |
en Required | String: Event name | Enrichment - view_cart |
Checkout Started
| Output Key | Description | Expected Input |
|---|---|---|
cu | String: Currency (ISO 4217) | properties.currency (default: USD) |
ep-transaction_id | String: Transaction ID | properties.order_id |
ep-coupon | String: Coupon code | properties.coupon |
epn-value | Number: Monetary value | Expression - Sum of price × quantity across all products |
epn-tax | Number: Tax amount | properties.tax |
epn-shipping | Number: Shipping cost | properties.shipping |
pr1, pr2... | String: Product information (encoded) | Expression - Products array encoded as indexed key-value pairs |
en Required | String: Event name | Enrichment - begin_checkout |
Payment Info Entered
| Output Key | Description | Expected Input |
|---|---|---|
cu | String: Currency (ISO 4217) | properties.currency (default: USD) |
ep-coupon | String: Coupon code | properties.coupon |
ep-payment_type | String: Payment method | properties.payment_method |
epn-value | Number: Monetary value | Expression - Sum of price × quantity across all products |
pr1, pr2... | String: Product information (encoded) | Expression - Products array encoded as indexed key-value pairs |
en Required | String: Event name | Enrichment - add_payment_info |
Order Completed
| Output Key | Description | Expected Input |
|---|---|---|
cu | String: Currency (ISO 4217) | properties.currency (default: USD) |
ep-transaction_id | String: Transaction ID | properties.order_id |
ep-coupon | String: Coupon code | properties.coupon |
epn-value | Number: Monetary value | Expression - Sum of price × quantity across all products |
epn-tax | Number: Tax amount | properties.tax |
epn-shipping | Number: Shipping cost | properties.shipping |
pr1, pr2... | String: Product information (encoded) | Expression - Products array encoded as indexed key-value pairs |
isConversion | Boolean: Mark as conversion | Enrichment - true |
en Required | String: Event name | Enrichment - purchase |
Order Refunded
| Output Key | Description | Expected Input |
|---|---|---|
cu | String: Currency (ISO 4217) | properties.currency (default: USD) |
ep-transaction_id | String: Transaction ID | properties.order_id |
ep-coupon | String: Coupon code | properties.coupon |
epn-value | Number: Monetary value | Expression - Sum of price × quantity across all products |
epn-tax | Number: Tax amount | properties.tax |
epn-shipping | Number: Shipping cost | properties.shipping |
pr1, pr2... | String: Product information (encoded) | Expression - Products array encoded as indexed key-value pairs |
en Required | String: Event name | Enrichment - refund |
Promotion Viewed
| Output Key | Description | Expected Input |
|---|---|---|
ep-creative_name | String: Creative name | properties.creative |
ep-creative_slot | String: Creative slot | properties.position |
ep-promotion_id | String: Promotion ID | properties.promotion_id |
ep-promotion_name | String: Promotion name | properties.name |
en Required | String: Event name | Enrichment - view_promotion |
Promotion Clicked
| Output Key | Description | Expected Input |
|---|---|---|
ep-creative_name | String: Creative name | properties.creative |
ep-creative_slot | String: Creative slot | properties.position |
ep-promotion_id | String: Promotion ID | properties.promotion_id |
ep-promotion_name | String: Promotion name | properties.name |
en Required | String: Event name | Enrichment - select_promotion |
Product Added to Wishlist
| Output Key | Description | Expected Input |
|---|---|---|
cu | String: Currency (ISO 4217) | properties.currency (default: USD) |
epn-value | Number: Monetary value | Expression - properties.value, falls back to price × quantity |
pr1 | String: Product information (encoded) | Expression - Single product encoded as key-value pairs |
en Required | String: Event name | Enrichment - add_to_wishlist |
Required & Recommended Identifiers
These identifiers must be mapped to Google Analytics 4 - Collect for successful user matching. Without these IDs, events sent to GA4 may not appear in your dashboard. Required and recommended IDs are mapped as Global parameters to ensure they are added to every event.
| Attribute | Description | Example | Sync Injector Required? |
|---|---|---|---|
cid Required | Client ID | 35009a79-1a05-49d7-b876-2b884d0f825b | Yes |
ua Highly Recommended | User agent (for platform data) | Opera/9.80 (Windows NT 6.0)... | No |
_uip Highly Recommended | User IP (for geolocation) | 1.2.3.4 | No |
sid Highly Recommended | Session ID (for session data) | AJKDLSJFKLJ2390SKDFJLKJ23KJF9 | Yes |
sct Highly Recommended | Session count (for session data) | 620 | Yes |
Additional Identifiers
These identifiers should be mapped whenever possible to ensure highest user match rates:
| Attribute | Description | Example |
|---|---|---|
gclid | Google Click Identifier (Google Ads, Search Ads 360) | CjwKCAjwt-OwBhBnEiwAgwzrUkyN... |
dclid | Display Click Identifier (DV360 conversions) | CKDdz-fE_IUDFYtTCQkdbyMOPg |
Additional Google Analytics 4 - Collect Documentation
- [GA4] Recommended events
- [GA4] Custom events
- Enhanced measurement events
- [GA4] Tag your Google Ads final URLs
Updated 8 days ago