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.

AspectGA4 Measurement (Recommended)GA4 Collect
Endpointhttps://www.google-analytics.com/mp/collecthttps://google-analytics.com/g/collect
MethodPOSTGET
Data FormatJSON payload (structured)URL parameters (flat)
AuthenticationAPI_SECRET + MEASUREMENT_IDMEASUREMENT_ID only
Product DataStructured items arrayEncoded strings (pr1, pr2, etc.)
Consent SupportFull (ad_user_data, ad_personalization)Limited
Device ObjectFull device informationNot available
Geolocationip_override, user_location (Oct 2024)Native (_uip)
Batch ProcessingEvents arrayIndividual events
Debug ModeVia validation endpointep.debug_mode=true
Use CaseServer-side tracking, batch processingBrowser-like behavior, simple setup
Release StatusMature (2022), actively enhancedNewer (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_ID is 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 gclid and dclid at 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 in context.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

  1. Log in to your Google Analytics account.
  2. Navigate to the Admin section.
  3. In the "Property settings" column, expand "Data collection and modification", click on "Data Streams."
  4. Here, you'll find a list of data streams associated with the property.
  5. Click on the data stream for which you want to find the measurement ID.
  6. 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.

ArchitectureDescriptionDocumentation
GA4 Sync - DecoupledGA4 as a separate sync under parent Google Tag SettingsGtag Decoupled: sync GA4
Google Tag Sync - Coupled (Legacy)GA4 bundled with CM360/Google Ads in single Google Gtag syncGtag 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 ParameterDescription
MEASUREMENT_IDThe 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:

  1. Go to Pipelines > Select your Pipeline
  2. Click the Right drop-down > Add Integration
  3. 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 KeyDescriptionExpected Input
gclidString: Google Ad Click IDExpression - Third segment extracted from GA click ID cookie value
dclidString: Google Display Ads IDExpression - Third segment extracted from Display click ID cookie value
cid RequiredString: Client IDExpression - Extracted from GA cookie (_ga), falls back to anonymousId
dlString: Page URL (document location)context.page.url
dtString: Page titlecontext.page.title
drString: Page referrercontext.page.referrer
ua Highly RecommendedString: User agent (required for platform data)context.userAgent
_uip Highly RecommendedString: User IP address (required for geolocation)context.ip
ciString: Campaign IDcontext.campaign.id
csString: Campaign sourcecontext.campaign.source
cmString: Campaign mediumcontext.campaign.medium
cnString: Campaign namecontext.campaign.name
ccString: Campaign contentcontext.campaign.content
ckString: Campaign termcontext.campaign.term
sid Highly RecommendedString: Session ID (required for session data)context.providers.googleGtag.data.sessionID
sct Highly RecommendedInteger: Session count (required for session data)context.providers.googleGtag.data.sessionCount
_et RequiredInteger: Engagement time in millisecondsproperties.engagement_time_milliseconds (default: 1)
tid RequiredString: Tracking/Measurement IDEnrichment - MEASUREMENT_ID
v RequiredInteger: Protocol version (must equal 2)Enrichment - 2
isDebugModeBoolean: Enable debug modeEnrichment - false (set to true to enable; connection transform converts to ep.debug_mode=true)
up.metarouter_anonymousidString: MetaRouter anonymous ID sent as user propertyExpression - 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:

  1. Navigate to Admin > Data Display > Custom Definitions in GA4
  2. Click Create Custom Dimension
  3. Name your dimension, set Scope to User, and set User Property to metarouter_anonymousid

Event Specific

Page

Output KeyDescriptionExpected Input
en RequiredString: Event nameEnrichment - page_view
isConversionBoolean: Mark as conversionEnrichment - true

Pro

Output KeyDescriptionExpected Input
ep-search_termString: Search termproperties.query
en RequiredString: Event nameEnrichment - search

Product List Viewed

Output KeyDescriptionExpected Input
ep-item_list_idString: List IDproperties.list_id
ep-item_list_nameString: List nameproperties.category
pr1, pr2...String: Product information (encoded)Expression - Products array encoded as indexed key-value pairs
en RequiredString: Event nameEnrichment - view_item_list

Product Clicked

Output KeyDescriptionExpected Input
pr1String: Product information (encoded)Expression - Single product encoded as key-value pairs
en RequiredString: Event nameEnrichment - select_item

Product Viewed

Output KeyDescriptionExpected Input
cuString: Currency (ISO 4217)properties.currency (default: USD)
epn-valueNumber: Monetary valueExpression - properties.value, falls back to price × quantity
pr1String: Product information (encoded)Expression - Single product encoded as key-value pairs
en RequiredString: Event nameEnrichment - view_item

Product Added

Output KeyDescriptionExpected Input
cuString: Currency (ISO 4217)properties.currency (default: USD)
epn-valueNumber: Monetary valueExpression - properties.value, falls back to price × quantity
pr1String: Product information (encoded)Expression - Single product encoded as key-value pairs
isConversionBoolean: Mark as conversionEnrichment - true
en RequiredString: Event nameEnrichment - add_to_cart

Product Removed

Output KeyDescriptionExpected Input
cuString: Currency (ISO 4217)properties.currency (default: USD)
epn-valueNumber: Monetary valueExpression - properties.value, falls back to price × quantity
pr1String: Product information (encoded)Expression - Single product encoded as key-value pairs
en RequiredString: Event nameEnrichment - remove_from_cart

Cart Viewed

Output KeyDescriptionExpected Input
cuString: Currency (ISO 4217)properties.currency (default: USD)
epn-valueNumber: Monetary valueExpression - Sum of price × quantity across all products
pr1, pr2...String: Product information (encoded)Expression - Products array encoded as indexed key-value pairs
en RequiredString: Event nameEnrichment - view_cart

Checkout Started

Output KeyDescriptionExpected Input
cuString: Currency (ISO 4217)properties.currency (default: USD)
ep-transaction_idString: Transaction IDproperties.order_id
ep-couponString: Coupon codeproperties.coupon
epn-valueNumber: Monetary valueExpression - Sum of price × quantity across all products
epn-taxNumber: Tax amountproperties.tax
epn-shippingNumber: Shipping costproperties.shipping
pr1, pr2...String: Product information (encoded)Expression - Products array encoded as indexed key-value pairs
en RequiredString: Event nameEnrichment - begin_checkout

Payment Info Entered

Output KeyDescriptionExpected Input
cuString: Currency (ISO 4217)properties.currency (default: USD)
ep-couponString: Coupon codeproperties.coupon
ep-payment_typeString: Payment methodproperties.payment_method
epn-valueNumber: Monetary valueExpression - Sum of price × quantity across all products
pr1, pr2...String: Product information (encoded)Expression - Products array encoded as indexed key-value pairs
en RequiredString: Event nameEnrichment - add_payment_info

Order Completed

Output KeyDescriptionExpected Input
cuString: Currency (ISO 4217)properties.currency (default: USD)
ep-transaction_idString: Transaction IDproperties.order_id
ep-couponString: Coupon codeproperties.coupon
epn-valueNumber: Monetary valueExpression - Sum of price × quantity across all products
epn-taxNumber: Tax amountproperties.tax
epn-shippingNumber: Shipping costproperties.shipping
pr1, pr2...String: Product information (encoded)Expression - Products array encoded as indexed key-value pairs
isConversionBoolean: Mark as conversionEnrichment - true
en RequiredString: Event nameEnrichment - purchase

Order Refunded

Output KeyDescriptionExpected Input
cuString: Currency (ISO 4217)properties.currency (default: USD)
ep-transaction_idString: Transaction IDproperties.order_id
ep-couponString: Coupon codeproperties.coupon
epn-valueNumber: Monetary valueExpression - Sum of price × quantity across all products
epn-taxNumber: Tax amountproperties.tax
epn-shippingNumber: Shipping costproperties.shipping
pr1, pr2...String: Product information (encoded)Expression - Products array encoded as indexed key-value pairs
en RequiredString: Event nameEnrichment - refund

Promotion Viewed

Output KeyDescriptionExpected Input
ep-creative_nameString: Creative nameproperties.creative
ep-creative_slotString: Creative slotproperties.position
ep-promotion_idString: Promotion IDproperties.promotion_id
ep-promotion_nameString: Promotion nameproperties.name
en RequiredString: Event nameEnrichment - view_promotion

Promotion Clicked

Output KeyDescriptionExpected Input
ep-creative_nameString: Creative nameproperties.creative
ep-creative_slotString: Creative slotproperties.position
ep-promotion_idString: Promotion IDproperties.promotion_id
ep-promotion_nameString: Promotion nameproperties.name
en RequiredString: Event nameEnrichment - select_promotion

Product Added to Wishlist

Output KeyDescriptionExpected Input
cuString: Currency (ISO 4217)properties.currency (default: USD)
epn-valueNumber: Monetary valueExpression - properties.value, falls back to price × quantity
pr1String: Product information (encoded)Expression - Single product encoded as key-value pairs
en RequiredString: Event nameEnrichment - 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.

AttributeDescriptionExampleSync Injector Required?
cid RequiredClient ID35009a79-1a05-49d7-b876-2b884d0f825bYes
ua Highly RecommendedUser agent (for platform data)Opera/9.80 (Windows NT 6.0)...No
_uip Highly RecommendedUser IP (for geolocation)1.2.3.4No
sid Highly RecommendedSession ID (for session data)AJKDLSJFKLJ2390SKDFJLKJ23KJF9Yes
sct Highly RecommendedSession count (for session data)620Yes

Additional Identifiers

These identifiers should be mapped whenever possible to ensure highest user match rates:

AttributeDescriptionExample
gclidGoogle Click Identifier (Google Ads, Search Ads 360)CjwKCAjwt-OwBhBnEiwAgwzrUkyN...
dclidDisplay Click Identifier (DV360 conversions)CKDdz-fE_IUDFYtTCQkdbyMOPg

Additional Google Analytics 4 - Collect Documentation