Google Analytics 4 Web Destination

Destination Info

Additional versions of this destination are available

This page is about the Google Analytics 4 Web Destination. See below for information about other versions of the Google destination:

Google Analytics 4 is Google’s Analytics property that you can use for both websites and applications. Google Analytics 4 has machine learning at its core to help surface insights and give you a more complete understanding of your customers across devices and platforms.

When you have Segment installed, you can use your existing Analytics 2.0 tracking implementation to fulfill your data collection needs with Google Analytics 4. When you enable the Google Analytics 4 Web destination, Segment loads the gtag.js library for you. To avoid duplicate data, remove the native gtag.js script from your page.

Consent mode

Google enforced consent on March 6, 2024 for European Economic Area (EEA) users. Learn more about consent mode and how to set it up.

Getting started

Before you connect Segment to Google Analytics 4, configure a Google Analytics 4 property in your Analytics account and enable any Custom Definitions in your GA4 Admin Panel. For more information, see Google’s article Set up Analytics for a website and/or app.

To connect the Google Analytics 4 Web destination:

  1. From the Segment web app, click Catalog, then click Destinations.
  2. Search for “Google Analytics 4 Web” in the Destinations Catalog, and select the destination.
  3. Click Configure Google Analytics 4 Web.
  4. Select the web source that will send data to Google Analytics 4 and follow the steps to name your destination. The web source chosen must use Analytics.js 2.0. For mobile source tracking, view the Firebase Destination.
  5. On the Settings tab, under Basic Settings, enter in the Measurement ID associated with your GA4 web stream.
  6. Set up your event mappings by following the steps in the Destinations Actions documentation on Customizing mappings.
  7. Analytics.js requires an initial Page call to send data to Google Analytics 4 Web. The Segment snippet includes this initial call by default.
  8. For GA4 to accept events on page, enable Set Configuration Mapping triggered by the first Segment event called after analytics.load(). Set Configuration Mapping calls the gtag(‘config’) command to enable tracking to your GA4 Measurement ID.

After you’ve set up and enabled the Set Configuration Mapping, enable at least one event in your Mappings tab. From there, view your events and parameters using the Google Realtime orDebugView reports. These two reports show you the events users trigger on your website as they occur. The DebugView report requires additional configuration before you can use it. Additional tools for debugging are to view all your Google enabled tracking via https://tagassistant.google.com(https://tagassistant.google.com){:target=”_blank”} or in your browser’s Dev Tools, view GA4 collect requests by filtering by /collect.

Google Analytics automatically populates some events and parameters. For example, there are Automatically Collected events collected by triggering the Set Configuration Mapping. Calling gtag(‘config’) and enabling Enhanced Measurement events, which are controlled by toggling “on” in your GA4 Admin panel, use event listeners to send events. All events tracked via GA4 Web populate some commonly used parameters like page_location without additional configuration. Review the Google Analytics event parameters{:target=”_blank” documentation for more information.

Google recommends that you use their Recommended events and properties to power certain built-in reports in Google Analytics 4. Segment’s Google Analytics 4 Web destination provides prebuilt mappings to automatically map your Segment spec events to the corresponding Google Analytics 4 events and properties. If your Segment events don’t follow the Segment spec exactly, you can modify the mappings. For example, Segment maps an Order Completed event to the Google Analytics 4 Purchase event, but if your company uses Products Purchase to indicate a purchase, you can map it in the Purchase action’s Event Trigger instead.

Segment recommends using the prebuilt mappings when possible. However, the Segment spec doesn’t have an equivalent event for every Google Analytics 4 Recommended event. If there are other recommended events you’d like to send, use the Custom Event action. For example, to send a spend_virtual_currency event, create a mapping for Custom Event, set up your Event Trigger criteria, and input a literal string of spend_virtual_currency as the Event Name. You can use the Event Parameters object to add fields that are in the spend_virtual_currency event such as value and virtual_currency_name. Remember to define custom parameters as custom dimensions and metrics within the GA4 Admin panel first.

Custom events and event naming

Before you create a custom event, make sure the event you want to create isn’t already collected through an Automatically Collected event or recommended as a Recommended event. Google Analytics 4 does not accept custom event names that include spaces. Segment replaces spaces in the Event Name in the Custom Event action with an underscore. As a result, you see custom events as snake_case in Google Analytics 4.

Event names are case-sensitive in Google Analytics 4. If you would like all event names to be lowercase, use the Lowercase Event Name setting when you create a Custom Event mapping and select Yes from the dropdown. If this setting is disabled, Google treats event names with different casing as distinct events.

Custom Events don’t appear in some of Google’s standard reports; you must set up custom reports for meaningful analysis.

Custom Events with Item Parameters

To pass item parameters, you must use Google Recommended Event names that accept the items array, in other words, Ecommerce Events. Item parameters do not pass to GA4 with a Custom Event name or any other Event name if the items array is not specified as a parameter.

Custom dimensions and metrics

With Google Analytics 4, you must create custom dimensions and metrics, also known as Custom Definitions, within the Google Analytics 4 Admin interface to link event parameters to the corresponding custom dimensions or metrics. When creating the dimension or metric, you can either select a parameter from the list of already collected fields or enter the name of the parameter you plan to collect in the future. For more information, see Google Analytics 4 Custom dimensions and metrics.

Understanding event parameters

Similar to how properties relate to Segment events, parameters provide additional information about the ways users interact with your website. For example, when someone views a product you sell, you can include parameters that describe the product they viewed, like product_name, category, and price.

Automatically Collected and Enhanced Measurement events include a defined set of parameters by default. Google also provides a set of required and optional parameters to include with each Recommended event, and you can add more event parameters when you need them. Segment recommends that you review GA4’s list of defined event parameters, as anything beyond that list is a custom event parameter. The Event collection limits also impact how many Custom Definitions your GA4 instance allows and how many parameters you can send with each event.

Conversion events

Some of Segment’s prebuilt Available Actions that map to Google’s recommended events are automatically marked as a conversion in your Analytics dashboard. For example, when you add an “Order Completed” event, it will show up in your Analytics dashboard as “purchase” with the Mark as conversion toggle toggled on by default. However, for other events, such as “Add to Cart”, you must manually toggle the Mark as conversion setting on in your Analytics dashboard. If you don’t mark the event as a conversion, it will not show up as a conversion in your built-in reports. You can read more about conversion events in Google’s documentation.

Consent mode is a feature provided by Google in the context of its products, particularly the Gtag library and Google Analytics. As of March 6, 2024, Google announced that consent mode must function for European Economic Area (EEA) users, otherwise data from EEA users won’t process.

Consent mode in the Gtag library and Google Analytics is designed to help website owners comply with privacy regulations, such as the General Data Protection Regulation (GDPR) in the European Union. It allows website owners to adjust how these tools use and collect data based on user consent.

With consent mode, you can configure your website to dynamically adjust the tracking behavior of the Gtag library and Google Analytics based on the user’s consent status. If a user provides consent to data processing, both the Gtag library and Google Analytics can collect and use that data for analysis. If a user doesn’t provide consent, both tools limit data collection to essential functions, helping businesses respect user privacy preferences.

Consent mode may involve updates to your sources outside of Segment, such as incorporating a consent management system for consent functionality.

See set up consent mode on websites for more information.

To enable consent mode for your Google Analytics 4 Web destination:

  1. Navigate to Connections > Destinations and select your Google Analytics 4 Web** destination.
  2. Go to the Settings tab of the destination.
  3. Click the toggle on for Enable Consent Mode, this calls gtag(‘consent’,’default’) with the defined parameters when the gtag library loads.
  4. Set the following fields with your organization’s determination of granted or denied:

    Field Value
    Default Ad Storage Consent State Granted or Denied
    Default Analytics Storage Consent State Granted or Denied
    Ad User Data Consent State Granted or Denied
    Ad Personalization Consent State Granted or Denied
  5. Use your consent management platform to prompt the visitor. Ask the visitor to grant or deny consent for the applicable types.
  6. Pass the updated state as properties in the page() event after the next page load if you decide to change the consent defaults. For example,

     analytics.page('Consent Update', {
         'Ads Storage Consent State': 'false',
         'Analytics Storage Consent State': 'false'
     });
    
  7. As soon as the page loads and the set configuration fires to the Google Analytics SDK, Segment issues a consent mode update command. Map the properties you defined to collect consent state changes to the Set Configurations Fields mapping. You can choose to do this from 1 of 2 options in steps 4 and 5. 1. Navigate to Connections > Destinations and select your Google Analytics 4 Web destination. 2. Go to the mappings tab of the destination. 3. Select the mapping you want to edit.’ 4. (Option 1) Under the Select mappings section, select Granted for these fields: * Ads Storage Consent State * Analytics Storage Consent State * Ad User Data Consent State * Ad Personalization Consent State You can manually select Granted or Denied from the dropdown menu for Advanced consent mode settings, and type in granted or denied for basic consent mode settings. 5. (Option 2) Under the Select mappings section, create an event variable to directly grab the value from the payload (for example, properties.adStorageConsentState). Ensure it translates to granted or denied. You can use an insert or replace function to translate other values to granted or denied. Do this for these fields: * Ads Storage Consent State * Analytics Storage Consent State * Ad User Data Consent State * Ad Personalization Consent State

When these properties are available, they send to the update command.

If you have any questions setting up consent mode, reach out to friends@segment.com.

Destination Settings

Setting Description
Ad Personalization Consent State

Consent state indicated by the user for ad cookies. Value must be “granted” or “denied.” This is only used if the Enable Consent Mode setting is on.

Ad User Data Consent State

Consent state indicated by the user for ad cookies. Value must be “granted” or “denied.” This is only used if the Enable Consent Mode setting is on.

Allow Ad Personalization Signals

Set to false to disable all advertising features. Set to true by default.

Allow Google Signals

Set to false to disable all advertising features. Set to true by default.

Cookie Domain

Specifies the domain used to store the analytics cookie. Set to “auto” by default.

Cookie Expiration In Seconds

Every time a hit is sent to GA4, the analytics cookie expiration time is updated to be the current time plus the value of this field. The default value is two years (63072000 seconds). Please input the expiration value in seconds. More information in Google Documentation

Cookie Flag

Appends additional flags to the analytics cookie. See write a new cookie for some examples of flags to set.

Cookie Path

Specifies the subpath used to store the analytics cookie. We recommend to add a forward slash, / , in the first field as it is the Default Value for GA4.

Cookie Prefix

Specifies a prefix to prepend to the analytics cookie name.

Cookie Update

Set to false to not update cookies on each page load. This has the effect of cookie expiration being relative to the first time a user visited. Set to true by default so update cookies on each page load.

Default Ads Storage Consent State

The default value for ad cookies consent state. This is only used if Enable Consent Mode is on. Set to “granted” if it is not explicitly set. Consent state can be updated for each user in the Set Configuration Fields action.

Default Analytics Storage Consent State

The default value for analytics cookies consent state. This is only used if Enable Consent Mode is on. Set to “granted” if it is not explicitly set. Consent state can be updated for each user in the Set Configuration Fields action.

Enable Consent Mode

Set to true to enable Google’s Consent Mode. Set to false by default.

Measurement ID Required.

The measurement ID associated with the web stream. Found in the Google Analytics UI under: Admin > Data Streams > Web > Measurement ID.

Page Views

Set to false to prevent the default snippet from sending page views. Enabled by default.

Wait Time to Update Consent State

If your CMP loads asynchronously, it might not always run before the Google tag. To handle such situations, specify a millisecond value to control how long to wait before the consent state update is sent. Please input the wait_for_update in milliseconds.

Available Presets

Google Analytics 4 Web has the following presets:

Preset Name Trigger Default Action
Set Configuration Fields Event type = "page"
Set Configuration Fields

Available Actions

Required fields may have changed

View the Google Analytics documentation for the most up-to-date list of required fields.

Build your own Mappings. Combine supported triggers with the following Google Analytics 4 Web-supported actions:

Mapping limits per destination

Individual destination instances have support a maximum of 50 mappings.

Add to Cart

This event signifies that an item was added to a cart for purchase.

Add to Cart is a Web action. The default Trigger is: type = "track" and event = "Product Added"

Click to show / hide fields

Field Description
User ID Type: STRING

A unique identifier for a user. See Google’s User-ID for cross-platform analysis and Reporting: deduplicate user counts documentation for more information on this identifier.

Currency Type: STRING

Currency of the items associated with the event, in 3-letter ISO 4217 format.

Products* Type: OBJECT

The list of products purchased.

Value Type: NUMBER

The monetary value of the event.

User Properties Type: OBJECT

The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s Custom user properties to learn how to set and register user properties.

Event Parameters Type: OBJECT

The event parameters to send to Google Analytics 4.

Send To Type: BOOLEAN

If the send_to parameter is not set, events are routed to all Tag Ids (AW-xxx, G-xxx) set via Google Tag

The term that was searched for.

Search is a Web action. The default Trigger is: type = "track" and event = "Products Searched"

Click to show / hide fields

Select Item

This event signifies an item was selected from a list.

Select Item is a Web action. The default Trigger is: type = "track" and event = "Product Clicked"

Click to show / hide fields

Field Description
User ID Type: STRING

A unique identifier for a user. See Google’s User-ID for cross-platform analysis and Reporting: deduplicate user counts documentation for more information on this identifier.

Item List Name Type: STRING

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

Item List Id Type: STRING

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

Products* Type: OBJECT

The list of products purchased.

User Properties Type: OBJECT

The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s Custom user properties to learn how to set and register user properties.

Event Parameters Type: OBJECT

The event parameters to send to Google Analytics 4.

Send To Type: BOOLEAN

If the send_to parameter is not set, events are routed to all Tag Ids (AW-xxx, G-xxx) set via Google Tag

View Item List

Log this event when the user has been presented with a list of items of a certain category.

View Item List is a Web action. The default Trigger is: type = "track" and event = "Product List Viewed"

Click to show / hide fields

Field Description
User ID Type: STRING

A unique identifier for a user. See Google’s User-ID for cross-platform analysis and Reporting: deduplicate user counts documentation for more information on this identifier.

Item List Id Type: STRING

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

Item List Name Type: STRING

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

Products* Type: OBJECT

The list of products purchased.

User Properties Type: OBJECT

The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s Custom user properties to learn how to set and register user properties.

Event Parameters Type: OBJECT

The event parameters to send to Google Analytics 4.

Send To Type: BOOLEAN

If the send_to parameter is not set, events are routed to all Tag Ids (AW-xxx, G-xxx) set via Google Tag

Sign Up

The method used for sign up.

Sign Up is a Web action. The default Trigger is: type = "track" and event = "Signed Up"

Click to show / hide fields

Custom Event

Send any custom event

Custom Event is a Web action. The default Trigger is: type = "track"

Click to show / hide fields

Field Description
Event Name* Type: STRING

The unique name of the custom event created in GA4. GA4 does not accept spaces in event names so Segment will replace any spaces with underscores. More information about GA4 event name rules is available in their docs.

Lowercase Event Name Type: BOOLEAN

If true, the event name will be converted to lowercase before sending to Google. Event names are case sensitive in GA4 so enable this setting to avoid distinct events for casing differences. More information about GA4 event name rules is available in their docs.

User ID Type: STRING

A unique identifier for a user. See Google’s User-ID for cross-platform analysis and Reporting: deduplicate user counts documentation for more information on this identifier.

User Properties Type: OBJECT

The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s Custom user properties to learn how to set and register user properties.

Event Parameters Type: OBJECT

The event parameters to send to Google Analytics 4.

Send To Type: BOOLEAN

If the send_to parameter is not set, events are routed to all Tag Ids (AW-xxx, G-xxx) set via Google Tag

Refund

This event signifies when one or more items is refunded to a user.

Refund is a Web action. The default Trigger is: type = "track" and event = "Order Refunded"

Click to show / hide fields

Field Description
User ID Type: STRING

A unique identifier for a user. See Google’s User-ID for cross-platform analysis and Reporting: deduplicate user counts documentation for more information on this identifier.

Currency Type: STRING

Currency of the items associated with the event, in 3-letter ISO 4217 format.

Order Id* Type: STRING

The unique identifier of a transaction.

Value Type: NUMBER

The monetary value of the event.

Affiliation Type: STRING

Store or affiliation from which this transaction occurred (e.g. Google Store).

Coupon Type: STRING

Coupon code used for a purchase.

Shipping Type: NUMBER

Shipping cost associated with the transaction.

Tax Type: NUMBER

Total tax associated with the transaction.

Products Type: OBJECT

The list of products purchased.

User Properties Type: OBJECT

The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s Custom user properties to learn how to set and register user properties.

Event Parameters Type: OBJECT

The event parameters to send to Google Analytics 4.

Send To Type: BOOLEAN

If the send_to parameter is not set, events are routed to all Tag Ids (AW-xxx, G-xxx) set via Google Tag

Add Payment Info

Send event when a user submits their payment information

Add Payment Info is a Web action. The default Trigger is: type = "track" and event = "Payment Info Entered"

Click to show / hide fields

Field Description
User ID Type: STRING

A unique identifier for a user. See Google’s User-ID for cross-platform analysis and Reporting: deduplicate user counts documentation for more information on this identifier.

Currency Type: STRING

Currency of the items associated with the event, in 3-letter ISO 4217 format.

Value Type: NUMBER

The monetary value of the event.

Coupon Type: STRING

Coupon code used for a purchase.

Payment Type Type: STRING

The chosen method of payment.

Products* Type: OBJECT

The list of products purchased.

User Properties Type: OBJECT

The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s Custom user properties to learn how to set and register user properties.

Event Parameters Type: OBJECT

The event parameters to send to Google Analytics 4.

Send To Type: BOOLEAN

If the send_to parameter is not set, events are routed to all Tag Ids (AW-xxx, G-xxx) set via Google Tag

View Cart

This event signifies that a user viewed their cart.

View Cart is a Web action. The default Trigger is: type = "track" and event = "Cart Viewed"

Click to show / hide fields

Field Description
User ID Type: STRING

A unique identifier for a user. See Google’s User-ID for cross-platform analysis and Reporting: deduplicate user counts documentation for more information on this identifier.

Currency Type: STRING

Currency of the items associated with the event, in 3-letter ISO 4217 format.

Value Type: NUMBER

The monetary value of the event.

Products* Type: OBJECT

The list of products purchased.

User Properties Type: OBJECT

The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s Custom user properties to learn how to set and register user properties.

Event Parameters Type: OBJECT

The event parameters to send to Google Analytics 4.

Send To Type: BOOLEAN

If the send_to parameter is not set, events are routed to all Tag Ids (AW-xxx, G-xxx) set via Google Tag

Set Configuration Fields

Set custom values for the GA4 configuration fields.

Set Configuration Fields is a Web action. The default Trigger is: type = "page"

Click to show / hide fields

Field Description
User ID Type: STRING

A unique identifier for a user. See Google’s User-ID for cross-platform analysis and Reporting: deduplicate user counts documentation for more information on this identifier.

User Properties Type: OBJECT

The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s Custom user properties to learn how to set and register user properties.

Ads Storage Consent State Type: STRING

Consent state indicated by the user for ad cookies. Value must be “granted” or “denied.” This is only used if the Enable Consent Mode setting is on.

Analytics Storage Consent State Type: STRING

Consent state indicated by the user for ad cookies. Value must be “granted” or “denied.” This is only used if the Enable Consent Mode setting is on.

Ad User Data Consent State Type: STRING

Consent state indicated by the user for ad cookies. Value must be “granted” or “denied.” This is only used if the Enable Consent Mode setting is on.

Ad Personalization Consent State Type: STRING

Consent state indicated by the user for ad cookies. Value must be “granted” or “denied.” This is only used if the Enable Consent Mode setting is on.

Campaign Content Type: STRING

Use campaign content to differentiate ads or links that point to the same URL. Setting this value will override the utm_content query parameter.

Campaign ID Type: STRING

Use campaign ID to identify a specific campaign. Setting this value will override the utm_id query parameter.

Campaign Medium Type: STRING

Use campaign medium to identify a medium such as email or cost-per-click. Setting this value will override the utm_medium query parameter.

Campaign Name Type: STRING

Use campaign name to identify a specific product promotion or strategic campaign. Setting this value will override the utm_name query parameter.

Campaign Source Type: STRING

Use campaign source to identify a search engine, newsletter name, or other source. Setting this value will override the utm_source query parameter.

Campaign Term Type: STRING

Use campaign term to note the keywords for this ad. Setting this value will override the utm_term query parameter.

Content Group Type: STRING

Categorize pages and screens into custom buckets so you can see metrics for related groups of information. More information in Google documentation.

Language Type: STRING

The language preference of the user. If not set, defaults to the user’s navigator.language value.

Page Location Type: STRING

The full URL of the page. If not set, defaults to the user’s document.location value.

Page Referrer Type: STRING

The referral source that brought traffic to a page. This value is also used to compute the traffic source. The format of this value is a URL. If not set, defaults to the user’s document.referrer value.

Page Title Type: STRING

The title of the page or document. If not set, defaults to the user’s document.title value.

Screen Resolution Type: STRING

The resolution of the screen. Format should be two positive integers separated by an x (i.e. 800x600). If not set, calculated from the user’s window.screen value.

Send Page Views Type: BOOLEAN

Selection overrides toggled value set within Settings

Event Parameters Type: OBJECT

The event parameters to send to Google Analytics 4.

Purchase

This event signifies when one or more items is purchased by a user.

Purchase is a Web action. The default Trigger is: type = "track" and event = "Order Completed"

Click to show / hide fields

Field Description
User ID Type: STRING

A unique identifier for a user. See Google’s User-ID for cross-platform analysis and Reporting: deduplicate user counts documentation for more information on this identifier.

Coupon Type: STRING

Coupon code used for a purchase.

Currency* Type: STRING

Currency of the items associated with the event, in 3-letter ISO 4217 format.

Products* Type: OBJECT

The list of products purchased.

Order Id* Type: STRING

The unique identifier of a transaction.

Shipping Type: NUMBER

Shipping cost associated with the transaction.

Tax Type: NUMBER

Total tax associated with the transaction.

Value Type: NUMBER

The monetary value of the event.

User Properties Type: OBJECT

The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s Custom user properties to learn how to set and register user properties.

Event Parameters Type: OBJECT

The event parameters to send to Google Analytics 4.

Send To Type: BOOLEAN

If the send_to parameter is not set, events are routed to all Tag Ids (AW-xxx, G-xxx) set via Google Tag

View Promotion

This event signifies a promotion was viewed from a list.

View Promotion is a Web action. The default Trigger is: type = "track" and event = "Promotion Viewed"

Click to show / hide fields

Field Description
User ID Type: STRING

A unique identifier for a user. See Google’s User-ID for cross-platform analysis and Reporting: deduplicate user counts documentation for more information on this identifier.

Creative Name Type: STRING

The name of the promotional creative.

Creative Slot Type: STRING

The name of the promotional creative slot associated with the event.

Location ID Type: STRING

The ID of the location.

Promotion ID Type: STRING

The ID of the promotion associated with the event.

Promotion Name Type: STRING

The name of the promotion associated with the event.

Products* Type: OBJECT

The list of products purchased.

User Properties Type: OBJECT

The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s Custom user properties to learn how to set and register user properties.

Event Parameters Type: OBJECT

The event parameters to send to Google Analytics 4.

Send To Type: BOOLEAN

If the send_to parameter is not set, events are routed to all Tag Ids (AW-xxx, G-xxx) set via Google Tag

Add to Wishlist

The event signifies that an item was added to a wishlist. Use this event to identify popular gift items in your app.

Add to Wishlist is a Web action. The default Trigger is: type = "track" and event = "Product Added to Wishlist"

Click to show / hide fields

Field Description
User ID Type: STRING

A unique identifier for a user. See Google’s User-ID for cross-platform analysis and Reporting: deduplicate user counts documentation for more information on this identifier.

Currency Type: STRING

Currency of the items associated with the event, in 3-letter ISO 4217 format.

Value Type: NUMBER

The monetary value of the event.

Products* Type: OBJECT

The list of products purchased.

User Properties Type: OBJECT

The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s Custom user properties to learn how to set and register user properties.

Event Parameters Type: OBJECT

The event parameters to send to Google Analytics 4.

Send To Type: BOOLEAN

If the send_to parameter is not set, events are routed to all Tag Ids (AW-xxx, G-xxx) set via Google Tag

Remove from Cart

This event signifies that an item was removed from a cart.

Remove from Cart is a Web action. The default Trigger is: type = "track" and event = "Product Removed"

Click to show / hide fields

Field Description
User ID Type: STRING

A unique identifier for a user. See Google’s User-ID for cross-platform analysis and Reporting: deduplicate user counts documentation for more information on this identifier.

Currency Type: STRING

Currency of the items associated with the event, in 3-letter ISO 4217 format.

Value Type: NUMBER

The monetary value of the event.

Products* Type: OBJECT

The list of products purchased.

User Properties Type: OBJECT

The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s Custom user properties to learn how to set and register user properties.

Event Parameters Type: OBJECT

The event parameters to send to Google Analytics 4.

Send To Type: BOOLEAN

If the send_to parameter is not set, events are routed to all Tag Ids (AW-xxx, G-xxx) set via Google Tag

Generate Lead

Log this event when a lead has been generated to understand the efficacy of your re-engagement campaigns.

Generate Lead is a Web action. The default Trigger is: type = "track"

Click to show / hide fields

Field Description
User ID Type: STRING

A unique identifier for a user. See Google’s User-ID for cross-platform analysis and Reporting: deduplicate user counts documentation for more information on this identifier.

Currency Type: STRING

Currency of the items associated with the event, in 3-letter ISO 4217 format.

Value Type: NUMBER

The monetary value of the event.

User Properties Type: OBJECT

The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s Custom user properties to learn how to set and register user properties.

Event Parameters Type: OBJECT

The event parameters to send to Google Analytics 4.

Send To Type: BOOLEAN

If the send_to parameter is not set, events are routed to all Tag Ids (AW-xxx, G-xxx) set via Google Tag

Select Promotion

This event signifies a promotion was selected from a list.

Select Promotion is a Web action. The default Trigger is: type = "track" and event = "Promotion Clicked"

Click to show / hide fields

Field Description
User ID Type: STRING

A unique identifier for a user. See Google’s User-ID for cross-platform analysis and Reporting: deduplicate user counts documentation for more information on this identifier.

Creative Name Type: STRING

The name of the promotional creative.

Creative Slot Type: STRING

The name of the promotional creative slot associated with the event.

Location ID Type: STRING

The ID of the location.

Promotion ID Type: STRING

The ID of the promotion associated with the event.

Promotion Name Type: STRING

The name of the promotion associated with the event.

Products Type: OBJECT

The list of products purchased.

User Properties Type: OBJECT

The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s Custom user properties to learn how to set and register user properties.

Event Parameters Type: OBJECT

The event parameters to send to Google Analytics 4.

Send To Type: BOOLEAN

If the send_to parameter is not set, events are routed to all Tag Ids (AW-xxx, G-xxx) set via Google Tag

View Item

This event signifies that some content was shown to the user. Use this event to discover the most popular items viewed.

View Item is a Web action. The default Trigger is: type = "track" and event = "Product Viewed"

Click to show / hide fields

Field Description
User ID Type: STRING

A unique identifier for a user. See Google’s User-ID for cross-platform analysis and Reporting: deduplicate user counts documentation for more information on this identifier.

Currency Type: STRING

Currency of the items associated with the event, in 3-letter ISO 4217 format.

Value Type: NUMBER

The monetary value of the event.

Products* Type: OBJECT

The list of products purchased.

User Properties Type: OBJECT

The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s Custom user properties to learn how to set and register user properties.

Event Parameters Type: OBJECT

The event parameters to send to Google Analytics 4.

Send To Type: BOOLEAN

If the send_to parameter is not set, events are routed to all Tag Ids (AW-xxx, G-xxx) set via Google Tag

Begin Checkout

This event signifies that a user has begun a checkout.

Begin Checkout is a Web action. The default Trigger is: type = "track" and event = "Checkout Started"

Click to show / hide fields

Field Description
User ID Type: STRING

A unique identifier for a user. See Google’s User-ID for cross-platform analysis and Reporting: deduplicate user counts documentation for more information on this identifier.

Coupon Type: STRING

Coupon code used for a purchase.

Currency Type: STRING

Currency of the items associated with the event, in 3-letter ISO 4217 format.

Products* Type: OBJECT

The list of products purchased.

Value Type: NUMBER

The monetary value of the event.

Event Parameters Type: OBJECT

The event parameters to send to Google Analytics 4.

User Properties Type: OBJECT

The user properties to send to Google Analytics 4. You must create user-scoped dimensions to ensure custom properties are picked up by Google. See Google’s Custom user properties to learn how to set and register user properties.

Send To Type: BOOLEAN

If the send_to parameter is not set, events are routed to all Tag Ids (AW-xxx, G-xxx) set via Google Tag

Login

Send event when a user logs in

Login is a Web action. The default Trigger is: type = "track" and event = "Signed In"

Click to show / hide fields

FAQ and troubleshooting

Debug mode

The Google Analytics 4 debug mode, DebugView is supported with the Google Analytics 4 Web destination. DebugView displays the events and user properties that Analytics collects from a user in real-time. This can be helpful when troubleshooting your implementation.

Send events from both the browser and the server

With Google Analytics 4 Web, events are sent from the browser to GA4. If you use Segment’s Google Analytics 4 Cloud destination to send events through the API and tie data between client-side and server-side, you need to pass the same Client ID from the browser and the server. To do this, fetch the Gtag-generated clientId on the web client and pass it to Segment as a property. For more information, see Google Analytics 4 destination: User Identification on the next steps. Additionally, when using Gtag, Google generates a session_id and session_number when a session begins. The session_id and session_number generated on the client can be passed as Event Parameters to stitch events sent through the API with the same session that was collected client-side, see Using Gtagjs and Google Analytics 4 Cloud Destination for more information and an example.

The client_id and the session_id are both cookies stored in the user browser. You can use Google gtag get commands or other cookie methods to parse these values from the _ga cookie and _ga_measurementId cookie:

  • If your _ga cookie is GA1.1.1783165678.1701112990 then 1783165678.1701112990 is your client_id
  • If your _ga_M12454XDR cookie is GS1.1.1710342977.347.1.1710343074.0.0.0 then 1710342977 is your session_id

You are not required to send a session number for server-side hits. Session metrics come from the client-side data after GA4 stitches server-side event data to the client-side session.

Segment recommends that you enable the GA4 Web destination first then incorporate GA4 Cloud destination to augment your client-side tracking, as a hybrid GA4 application is an advanced implementation. Segment also recommends that you have deep knowledge of GA4 session-stitching, troubleshooting, and known caveats of the GA4 Measurement Protocol prior to implementing the Google Analytics 4 destination.

Additional (unmapped) events are sent to GA4

Google Analytics 4 collects events triggered by basic interactions with your site. For more information about which interactions are automatically collected, see Google Analytics 4 Automatically Collected events.

Data takes a long time to appear in Google’s reports

Google may take 24-48 hours to process data sent to Google Analytics. As a result, the Google Analytics user interface may not reflect the most current data. The Google Analytics Realtime report displays activity on your site as it happens; however, events seen in Realtime reports do not always equate to how the data is processed in the standard reports. This disconnect between events seen in Realtime reports and Standard reports happens when a Custom Definition is not defined in the GA4 Admin panel.

Data is not sent to Google

For event data to be sent downstream to Google Analytics:

  1. Configure and enable the Set Configuration Fields mapping. This mapping is required for data to be sent downstream because it sets configuration to the GA4 Measurement ID indicated in the Settings and establishes data flow using the config command.
  2. Confirm you call analytics.page() on page load. Analytics.js requires an initial Page call to send data to Google Analytics 4 Web. The Segment snippet includes this initial call by default.
  3. Send data with an event: typically this is a page_view as your first event.

If you toggled Page Views in your Settings to “On”, the page_view event automatically sends when the Set Configuration Mapping is triggered

If you need to override this setting for your particular use case, see Can I override my send_page_view selection that I declared in Settings?

If no events are flowing to your GA4 instance, use one of the Debugging Tools to check the sequence of GA4 events.

Duplicate page_view events in GA4

If you are sending multiple gtag(‘config’) commands called from Set Configuration mapping on one page before a new DOM has loaded, and you have defined send_page_view: true with each ‘Config’ event, you may see duplicate page_view events sent to your GA4 measurement id. If this is the case, see Google’s documentation on Ignoring duplicate instances of on-page configuration.

If your site is a Single Page Application (SPA), you may want to leave the Ignore duplicate instances of on-page configuration toggle disabled in the Google Tag Admin as a new DOM is not called on each new page path. If you have a SPA, disabled the Ignore duplicate instances of on-page configuration toggle, and have multiple Set Configuration mappings, use Segment’s new Send Page Views field mapping to override the send_page_view parameter in your Settings. This selection takes precedence over what is defined in the Segment Settings. If you leave the selection for your destination undefined, it will fall back to what you selected in the Segment Settings.

If you enabled Enhanced Measurement, you might see additional page_view events. This happens when you enable the Page changes based on browser history events feature in the Advanced settings section of the pageviews settings. To avoid double counting page views on history state changes, disable the Page changes based on browser history events feature. See Google’s Manual pageviews documentation for more information.

Manually send page_view events

If you prefer to keep the Page Views setting disabled and manually send page_view events, see Google’s documentation, Manually send page_view events.

With Google Analytics 4 Web, you must configure a Custom Event mapping to manually send page_view events. When mapping the events, set the Event Name to page_view.

You can now override the send_page_view value defined in the Segment Settings for the GA4 destination. To override the send_page_view value, navigate to your Set Configuration Mapping, click “Show More Fields” to expose the field mapping, and select either True or False. This selection takes precedence over what is defined in the Segment Settings. If you leave this selection undefined, Segment uses the selection you made in the Segment Settings.

Tracking UTM Parameters

Segment automatically tracks UTM parameters when they are present in the URL and sends them to Google. For example, with the following URL, Segment would send email_variation1&utm_medium=email&utm_source=email_promo&utm_campaign=summer_sale&utm_id=abcd to Google: https://www.example.com/?utm_content=email_variation1&utm_medium=email&utm_source=email_promo&utm_campaign=summer_sale&utm_id=abcd

By default, if the UTM values are found in the page_location parameter, GA4 automatically maps the campaign parameters to their appropriate value. There is no additional configuration required, unless you want to override what GA4 defines. This is true for both Event mappings and the Set Configuration mapping. If you modify the output of the page_location and the UTM parameters are not included, this might result in erroneous acquisition and attribution mapping.

To observe this feature, trigger a Page call with UTM parameters present in the URL and navigate to the Realtime overview report in GA4 to see the resulting page_view event under the Event count by Event name card. The Acquisition card in the Realtime overview report reflects First User acquisition, but may not reflect the parameters of the event if this was a second session event.

To pass custom event parameters to all events on the page, navigate to your Set Configuration Mapping, click Show All Fields, and enter any custom Event Parameters, including page_view. Any event parameters that have the same parameter key as your other event mappings will take precedence over what is set in the Set Configuration Mapping.

To send custom item parameters, add the custom item parameter name in mappings where there is a Products array. Register your custom item parameter in the GA4 Admin panel if you would like this value processed in the GA4 UI. You can ONLY add custom item parameters in the Products array. If you add custom item parameters as an Event Parameter, they will be registered as an Event Parameter.

My Events Send to the wrong Google ID

In each Event Mapping, there is a “Send To” parameter. Set this to “True” if you would like to include the send_to parameter and only send the event to the measurement_id configured in your settings. If you select “False” or do not enter a selection, GA4 Events will broadcast to all measurement IDs, including Google Ads IDs, on the page. These measurement IDs may be set outside of Segment. For more info on how the send_to parameter works, see Google’s documentation on Group and Route Data.

Can I override my send_page_view selection that I declared in the Settings?

Yes. In the Set Configuration Mapping, click Show All Fields and scroll to Send Page Views. Your selection overrides what is set within the Settings. This is helpful if you are updating the user_id or user_properties for all events on the page where you want to call the config command but do not want to send a page_view.

Differences between the Google Analytics 4 Cloud and Google Analytics 4 Web destinations

Segment’s Google Analytics 4 Cloud server-side destination uses Google’s Measurement Protocol API to send event data server to server, whereas Segment’s Google Analytics 4 Web device-mode destination loads the gtag.js library client-side and uses Segment’s event data to map to gtag.js events directly. Each destination has its own advantages and disadvantages. Your choice between the two depends on your specific use case, technical expertise, and the platforms from which you want to track data.

User-provided data collection

Google has introduced a beta feature for collecting data provided by users, User-provided data collection. Note that this feature is currently not supported by Segment, and, acknowledging this feature policy in your Google Analytics 4 Account has irreversible effects.

This page was last modified: 14 Aug 2024



Get started with Segment

Segment is the easiest way to integrate your websites & mobile apps data to over 300 analytics and growth tools.
or
Create free account