Measure ecommerce

[GA4] Set up ecommerce events

Understand how users interact with the products and services you sell

Understanding how users interact with the products and services you sell can help you optimize the shopping experience on your ecommerce website or mobile app. For example, you can measure the products your users view most frequently and how product placement, promotions, and banners impact key events.

Got 3 mins? Help us improve the GA4 ecommerce documentation by taking a quick online survey.

Collect ecommerce data

To collect ecommerce data, you need to add ecommerce events to your website or app or in your Google Tag Manager container. Because these events require additional context to be meaningful, the events aren't sent automatically. Once you add the events and someone uses the website or app, you will start to see ecommerce data in Analytics.

Note: If you manage your site using Shopify as your website builder or CMS, some events will be automatically tracked through the Shopify Pixel.

Use the following drop-downs to see information about how to send the events:

Google Tag (Websites)

You can place ecommerce events anywhere below where you placed the Google tag. For example, all of the following spots are valid places for the events.

<!DOCTYPE html>
<html lang="en">
    <!-- Your tag goes here -->
    <!-- You can place ecommerce events here -->
    <title>The title of the page</title>
    <!-- You can place ecommerce events here -->
    <!-- You can place ecommerce events here -->
    <!-- The part of your site that's shown to users -->
    <!-- You can place ecommerce events here -->

For more information about how to send events, see Set up events. For more information about each event, see Measure ecommerce. For information about placing your Google tag, see About the Google tag.

Google Tag Manager (Websites)

You can place an ecommerce event anywhere in your data layer. Once an ecommerce event is in the data layer and you've created a Google Analytics 4 Configuration tag, create a Google Analytics 4 Event tag for the event.
To create a Google Analytics 4 Event tag for the event, follow these steps:
  1. In Google Tag Manager, click Tags > New.
  2. Click Tag Configuration > Google Analytics: GA4 Event.
  3. In Configuration Tag, select your Google Analytics 4 Configuration tag.
  4. In Event Name, enter the name of the event (for example, view_item_list).
  5. In Event Parameters, add a row for each event-level parameter.
    Event-level parameters are parameters that you include within the event, outside of the items array, such as the item_list_id and item_list_name parameters in the view_item_list event.
  6. In Parameter Name, enter a name for the parameter.
  7. In Value, click + next to the field and choose an existing variable or add a new one.
  8. Save and publish the container.

When you want to trigger an event based on a condition (for example, when someone clicks a button), create a trigger and then add the trigger to the Google Analytics 4 Event tag.

For more information about how to send events, see Set up events. For more information about each event, including about ecommerce parameters, see Measure ecommerce.

Google Analytics for Firebase (Mobile apps)

Once you install the Google Analytics for Firebase SDK, see Measure ecommerce in the Firebase documentation for the specific ecommerce events. All the events are the same as the ones for web, but the snippets differ depending on the programming language you use.
If you've installed the Google Analytics for Firebase SDK, you can also add Tag Manager to your app so you can remotely configure events and parameters within Tag Manager.

Verify your configuration in realtime

Reports and explorations can take up to 24 hours to populate with your ecommerce data. In the meantime, you can verify whether you've set up your ecommerce events correctly by enabling debug mode. Once you enable debug mode, you can use DebugView to see your data in realtime.

Add parameters to ecommerce events

Parameters provide context on the ways in which customers interact with the products or services you sell. Information about the specific products or services you sell belongs at the item level (i.e., within an items array). Information about user interactions with those products or services belongs at the event level (i.e., outside of the items array).

For example, someone clicks a Purchase button on your website, which triggers a purchase event to fire. Along with the purchase event, you could include the total amount that the customer spent (at the event level) and the amount that a specific item cost (at the item level).

The following code snippet for the Google tag illustrates where these parameters go:

gtag("event", "view_item", {
  // Event-level parameters
  items: [
      // Item-level parameters

The recommended ecommerce parameters will be automatically collected into dimensions and metrics in Analytics available for reporting. Any parameters that are attributes of your data (such as the color or size of a shirt) populate dimensions, while any parameters that are quantitative measurements (such as numbers, averages, ratios, and percentages) populate metrics.

If you are sending custom parameters in your ecommerce events and want to view them in reporting, see Custom dimensions and metrics.

For more information on setting up event parameters, see Set up event parameters.

Understand the ecommerce events

Google Analytics provides a number of pre-built events that can help you start collecting information about how users interact with your store. Because the ecommerce events automatically populate dimensions and metrics and Google performs calculations to provide you with more valuable insights, you should use these events instead of creating your own custom events.


Promotions are a way of advertising one part of your website or app from another part of your website or app. For example, promotions include banners and pop-up boxes that direct customer attention to updates and discounts that are important to your business.

You can measure when users interact with your promotions and the impact of those promotions on key events by adding the view_promotion and select_promotion events. For more information, see Apply promotions.

When you add these events to your website or app, make sure to include the event-level promotion_id and promotion_name parameters. The parameters can help you identify the promotions that users interact with. The promotion name and ID are up to you — but make sure you assign the names and IDs consistently across your site or app.

If you want to measure when someone makes a purchase after they view or click a promotion, make sure to add at least one of the parameters — promotion_id or promotion_name — to every subsequent ecommerce event.


You can measure full and partial refunds using the refund event. A full refund includes all the items purchased, while a partial refund includes only some of the items purchased. Make sure to include each refunded item in an items array, regardless of whether you issue a full or partial refund. For more information, see Make a purchase or issue a refund.

See your ecommerce data

Your ecommerce data populates dimensions and metrics that you can access throughout Google Analytics, in BigQuery, and using the Google Analytics Data API.

The Ecommerce purchases and Monetization overview reports surface ecommerce information automatically. Explorations, BigQuery, and the Data API let you perform ad-hoc analysis and enable you to build custom tools outside of Analytics. To see ways to analyze your ecommerce data, see Ecommerce exploration solutions.

Was this helpful?

How can we improve it?
Clear search
Close search
Google apps
Main menu