This article is about Google Analytics 4 properties. Refer to the Universal Analytics section if you're still using a Universal Analytics property, which will stop processing data on July 1, 2023 (October 1, 2023 for Analytics 360 properties).

[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 conversions.

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.

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">
<head>
    <!-- Your tag goes here -->
    <!-- You can place ecommerce events here -->
    
    <title>The title of the page</title>
    <!-- You can place ecommerce events here -->
</head>
<body>
    <!-- You can place ecommerce events here -->
    <!-- The part of your site that's shown to users -->
    <!-- You can place ecommerce events here -->
</body>
</html>

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

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. 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, 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 the DebugView report 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
    }
  ]
});

All of the information that Google collects from the item and event-level parameters populate dimensions and metrics in Analytics. 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.

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

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 conversions by adding the view_promotion and select_promotion events.

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.

Refunds

Full refunds are refunds in which a customer returns all the items they purchased from your store, while partial refunds are refunds in which a customer returns only some of the items they purchased from your store. 

Google Analytics enables you to measure both full and partial refunds using the refund event. To measure a full refund, include the original transaction ID in the refund event. The transaction ID should be the original transaction ID from when the person made the purchase.

You don't need to include an items array when issuing a full refund. To measure a partial refund, include both the transaction ID and an items array with the specific items that the customer is returning.

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?
Search
Clear search
Close search
Google apps
Main menu
Search Help Center
true
69256
false
false