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.

MetaRouter has two integrations for GA4. The GA4 - Collect integration uses the collect endpoint for data and measurement, and it is the recommended integration for GA4. For more information about Google Analytics 4- Measurement, please see here.


Google Analytics 4 - Collect Endpoint vs Measurement Protocol

Collect Endpoint:

  • More data accuracy in
    • Age demographic
    • Page count
    • Session start events
  • Cannot collect screen resolution data

Measurement Protocol:

  • Can collect screen resolution data
  • More data on device category

Important Notes & Limitations

  • 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.
  • No user engagement reporting.
  • Cross network reporting may not be present in user and traffic acquisition reports.

Getting Started - From Your Google Analytics Account

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. Ex, “G-XXXXX00000”.

Getting Started - From Your MetaRouter Account

Adding a Google Analytics - Collect integration.

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.


Adding a Google Gtag Sync

To gather the cid, gclid (Google click ID) value, dclid (Display click ID) value, session ID, and session count, you must add a Google Gtag sync.

  1. From the Pipelines page, find the pipeline associated with the web property you’d like to add a sync to. Hover over the three dot dropdown and select “Build AJS File.”
  2. In the Identity Syncs section, select the Google Gtag sync.
  3. Fill out the following fields:
    1. GTAG.js Tag ID - The Tag ID in GA4, also known as the Measurement ID, can be found in Data Streams. Alternatively, you can find it in your GTAG settings. Examples of Tag IDs include GT-XXXXXXXXX, G-XXXXXXXXX, and AW-XXXXXXXXX. For more information on locating the GTAG.js Tag ID, please refer to this guide
    2. Destination IDs - Allows the sync to connect and direct events to the correct Google product. For Google Ads, the destination ID is the same as the conversion tracking ID, for example AW-98765.
    3. Floodlight Advertiser ID Object - The Floodlight Advertiser ID. This is not required for the Google Ads integration, but it is used for other Google integrations such as Campaign Manager.
    4. Cookie Lifetime (in days) - 45 days default
    5. Fire on Re-sync - Re-syncs for an updated identifier when an Identify call is made.
    6. Send MetaRouterSync to GA4 - Sends a MetaRouterSync event to GA4 when the sync is loaded on the page.
    7. Enable Google Consent Mode - If enabled, consent categories 'ad _storage, 'ad_user_data', 'ad _personalization', 'analytics_storage' will be sent to Google when user is opt-in or opt -out
    8. Advanced Consent Mode Type (when consent mode is enabled) - If consent mode is enabled, the consent mode will be set to advanced' when this is on, and 'basic' when this is off
  4. Scroll down and click the Save and Build File button.
  5. Deploy your AJS file to propagate changes to your web property.

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 - Collect’s API documentation.

Global

Global mappings will be applied to all events. If your parameter names do not match the Expected Inputs provided, you will need to overwrite the Inputs provided with your own.

Output Key

Description

Expected Input

gclid

Type: String
Specifies the Google Ad Id.

context.providers.googleGtag.data.gclid

dclid

Type: String
Specifies the Google Display Ads Id.

context.providers.googleGtag.data.dclid

cid
Required

Type: String
Client ID.

N/A - Expression

dl

Type: String
Page URL.

context.page.url

dt

Type: String
Page title.

context.page.title

dr

Type: String
Page referrer.

context.page.referrer

ua
Highly Recommended

Type: String
User agent, required if platform data is needed.

context.userAgent

_uip
Highly Recommended

Type: String
User IP address, required if geolocation data is needed.

context.ip

ci

Type: String
Campaign ID.

context.campaign.id

cs

Type: String
Campaign source.

context.campaign.source

cm

Type: String
Campaign medium.

context.campaign.medium

cn

Type: String
Campaign name.

context.campaign.name

cc

Type: String
Campaign conent.

context.campaign.content

ck

Type: String
Campaign term.

context.campaign.term

sid
Highly Recommended

Type: String
Session ID, required if session data is needed.

context.providers.googleGtag.data.sessionID

sct
Highly Recommended

Type: Integer
Session count, required if session data is needed.

context.providers.googleGtag.data.sessionCount

_et
Required

Type: Integer
Engagement time in milliseconds: currently hardcoded to 1

N/A - Expression

tid
Required

Type: String
Tracking ID, otherwise known as Measurement ID in GA4.

Enrichment - MEASUREMENT_ID

v
Required

Type: Integer
Must equal 2.

Enrichment - 2

isDebugMode

Type: Boolean
Must be true.

Enrichment - true

Type: String
Empty expression field used to send a user parameter to GA4*. Default setting is to send the anonymous ID as a user parameter.

N/A - Expression

*Note: You must set up user parameters in GA4 as a custom dimension to avoid errors with this function. To do this:

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

Event Specific

page

Output Key

Description

Expected Input

en Required

Type: String
Event name.

Enrichment - page_view

isConversion

Type: Boolean
Mark true if event is a conversion.

Enrichment - true


cart_viewed

Output Key

Description

Expected Input

cu

Type: String
Currency of the purchase or items associated with the event, in 3-letter ISO_4217 format.

properties.currency

epn-value

Type: Number
Monetary value of the event that occurred.

N/A - Expression

en
Required

Type: String
Event name.

Enrichment - view_cart


product_added

Output Key

Description

Expected Input

cu

Type: String
Currency of the purchase or items associated with the event, in 3-letter ISO_4217 format.

properties.currency

epn-value

Type: Number
Monetary value of the event that occurred.

N/A - Expression

pr1

Type: String
Product information.

N/A - Expression

isConversion

Type: Boolean
Mark true if event is a conversion.

Enrichment - true

en
Required

Type: String
Event name.

Enrichment - add_to_cart


order_refunded

Output Key

Description

Expected Input

cu

Type: String
Currency of the purchase or items associated with the event, in 3-letter ISO_4217 format.

properties.currency

ep-transaction_id

Type: String
The unique identifier of a transaction.

properties.order_id

ep-coupon

Type: String
The coupon name or code associated with an event.

properties.coupon

epn-value

Type: Number
Monetary value of the event that occurred.

N/A - Expression

epn-tax

Type: Number
The tax cost associated with a transaction.

properties.tax

epn-shipping

Type: Number
The shipping cost associated with a transaction.

properties.shipping

en
Required

Type: String
Event name.

Enrichment - ``


product_viewed

Output Key

Description

Expected Input

cu

Type: String
Currency of the purchase or items associated with the event, in 3-letter ISO_4217 format.

properties.currency

epn-value

Type: Number
Monetary value of the event that occurred.

N/A - Expression

pr1

Type: String
Product information.

N/A - Expression

isConversion

Type: Boolean
Mark true if event is a conversion.

Enrichment - true

en
Required

Type: String
Event name.

Enrichment - view_item


order_completed

Output Key

Description

Expected Input

cu

Type: String
Currency of the purchase or items associated with the event, in 3-letter ISO_4217 format.

properties.currency

ep-transaction_id

Type: String
The unique identifier of a transaction.

properties.order_id

ep-coupon

Type: String
The coupon name or code associated with an event.

properties.coupon

epn-value

Type: Number
Monetary value of the event that occurred.

N/A - Expression

epn-tax

Type: Number
The tax cost associated with a transaction.

properties.tax

epn-shipping

Type: Number
The shipping cost associated with a transaction.

properties.shipping

isConversion

Type: Boolean
Mark true if event is a conversion.

Enrichment - true

en
Required

Type: String
Event name.

Enrichment - purchase


product_clicked

Output Key

Description

Expected Input

pr1

Type: String
Product information.

N/A - Expression

en
Required

Type: String
Event name.

Enrichment - select_item


product_removed

Output Key

Description

Expected Input

cu

Type: String
Currency of the purchase or items associated with the event, in 3-letter ISO_4217 format.

properties.currency

epn-value

Type: Number
Monetary value of the event that occurred.

N/A - Expression

pr1

Type: String
Product information.

N/A - Expression

en
Required

Type: String
Event name.

Enrichment - remove_from_cart


checkout_started

Output Key

Description

Expected Input

cu

Type: String
Currency of the purchase or items associated with the event, in 3-letter ISO_4217 format.

properties.currency

ep-transaction_id

Type: String
The unique identifier of a transaction.

properties.order_id

ep-coupon

Type: String
The coupon name or code associated with an event.

properties.coupon

epn-value

Type: Number
Monetary value of the event that occurred.

N/A - Expression

epn-tax

Type: Number
The tax cost associated with a transaction.

properties.tax

epn-shipping

Type: Number
The shipping cost associated with a transaction.

properties.shipping

en
Required

Type: String
Event name.

Enrichment - begin_checkout


promotion_viewed

Output Key

Description

Expected Input

ep-creative_name

Type: String
The name of a creative used in a promotion.

properties.creative

ep-creative_slot

Type: String
The name of the promotional creative slot associated with an event.

properties.position

ep-promotion_id

Type: String
The ID of the promotion associated with an event.

properties.promotion_id

ep-promotion_name

Type: String
The name of the promotion associated with an event.

properties.name

en
Required

Type: String
Event name.

Enrichment - view_promotion


products_searched

Output Key

Description

Expected Input

ep-search_term

Type: String
The term that was searched for.

properties.query

en
Required

Type: String
Event name.

Enrichment - search


promotion_clicked

Output Key

Description

Expected Input

ep-creative_name

Type: String
The name of a creative used in a promotion.

properties.creative

ep-creative_slot

Type: String
The name of the promotional creative slot associated with an event.

properties.position

ep-promotion_id

Type: String
The ID of the promotion associated with an event.

properties.promotion_id

ep-promotion_name

Type: String
The name of the promotion associated with an event.

properties.name

en
Required

Type: String
Event name.

Enrichment - select_promotion


product_list_viewed

Output Key

Description

Expected Input

ep-item_list_id

Type: String
The ID of the list in which the item was presented to the user.

properties.list_id

ep-item_list_name

Type: String
The name of the list in which the item was presented to the user.

properties.category

en
Required

Type: String
Event name.

Enrichment - view_item_list


payment_info_entered

Output Key

Description

Expected Input

cu

Type: String
Currency of the purchase or items associated with the event, in 3-letter ISO_4217 format.

properties.currency

ep-coupon

Type: String
The coupon name or code associated with an event.

properties.coupon

ep-payment_type

Type: String
The chosen method of payment.

properties.payment_method

epn-value

Type: Number
Monetary value of the event that occurred.

N/A - Expression

en
Required

Type: String
Event name.

Enrichment - add_payment_info


product_added_to_wishlist

Output Key

Description

Expected Input

cu

Type: String
Currency of the purchase or items associated with the event, in 3-letter ISO_4217 format.

properties.currency

epn-value

Type: Number
Monetary value of the event that occurred.

N/A - Expression

pr1

Type: String
Product information.

N/A - Expression

en
Required

Type: String
Event name.

Enrichment - add_to_wishlist


Required & Recommended Identifiers

These identifiers must be mapped to Google Analytics 4 - Collect in order for successful user matching to occur. Without these IDs, any events sent to Google Analytics 4 - Collect will not appear in your dashboard. For your convenience, required and recommended IDs are mapped as Global parameters to ensure they are added to every event.

Attribute

Example

Sync Injector Required?

cid Required

35009a79-1a05-49d7-b876-2b884d0f825b

Yes

ua
Highly Recommended

Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14

No

uip
Highly Recommended

1.2.3.4

No

sid
Highly Recommended

AJKDLSJFKLJ2390SKDFJLKJ23KJF9

Yes

sct
Highly Recommended

620

Yes


Additional Identifiers

These identifiers should be mapped to Google Analytics 4 - Collect whenever possible to ensure the highest user match rates possible. If using these identifiers, they must be added as Global or Event Specific mappings.

AttributeDescriptionExample
gclidA Google Click Identifier generated by Google Ads or Search Ads 360.&gclid=CjwKCAjwt-OwBhBnEiwAgwzrUkyNMRwtorgWNStUyWMG50WbzKNMWAFeWOHtq5q0cEbAHYKX7a4hNBoCwugQAvD_BwE
dclidConversions can be attributed to ad clicks through the use of Display Click IDs (DCLIDs), typically used for DV360 conversions.&dclid=CKDdz-fE_IUDFYtTCQkdbyMOPg

Additional Google Analytics 4 - Collect Documentation