GA4 and GTM Guide for E-commerce
Google Analytics 4 and Google Tag Manager Guide for Ecommerce
Effective data tracking is critical for ecommerce sites. Understanding how users interact with your website can make all the difference to securing sales and ensuring the success of your business.
Integrating Google Tag Manager (GTM) and Google Analytics 4 (GA4) is a crucial aspect of ensuring your ecommerce data is insightful and accurate.
In our comprehensive guide, we will take you through the key information you need to successfully set up GTM and GA4 for ecommerce sites.
How does ecommerce event tracking work in GA4?
Tracking ecommerce events in GA4 is fundamentally similar to tracking other types of events. You’ll set up tags or code to trigger when specific events take place. You’ll then be able to access information about these events within GA4.
GA4’s predecessor, Universal Analytics, used the Enhanced Ecommerce model to house most ecommerce event tracking. In July 2023, Google Universal Analytics ceased processing data. This necessitated a transition to Google Analytics 4.
In GA4, ecommerce tracking is more integrated into overall event tracking processes. This allows for a more fluid ability to track ecommerce events. When using GA4, you can more easily get a holistic image of what’s happening on your site compared to UA.
It’s also important to note changes in metrics and terminology between UA and GA4. Check out Google’s complete guide to comparing metrics in UA and GA4 here.
As with any GA4 set-up, you have the option to manually add GA4 code to your website for event tracking. Alternatively, you can use tag-based solutions like Google Tag Manager.
This guide will focus on the latter approach.
Table of Contents
- Introduction
- How does ecommerce event tracking work in GA4?
- How to set up GA4 ecommerce event tracking
- Types of ecommerce events in GA4
- What product data can be tracked in GA4
- Key ecommerce events in GA4
- What is the GA4 ecommerce purchase report?
- Complying with the GDPR and CCPA while tracking ecommerce events in GA4
- Improve your ecommerce reporting with DataTrue
How to set up GA4 ecommerce event tracking
Let’s briefly go over the basic process of setting up event tracking in GA4. For this section, we will focus on setting up ecommerce event tracking where a data layer is in use on your website.
For a more in-depth explanation and information on setting up events without a data layer, check out our in-depth guide to setting up GA4 event tracking.
Guide to set up GA4 event tracking
- Create a GA4 event tag in your Google Tag Manager container.
- Configure your GA4 event tag with your desired parameters, inputting an appropriate name in the left field and selecting the data layer variable with the relevant information in the right field.
- In the GA4 event tag, add a trigger. In the event name field, enter the name of the data layer event you want to trigger the tag.
- Click “Preview” and trigger relevant events on your website. In the GTM preview pane, ensure that the correct event data is being captured and sent to GA4.
- Publish your changes.
- Test your changes after publication and on a regular, ongoing basis.
Types of ecommerce events in GA4
There are 4 major event types in GA4. 2 of these event types are collected in GA4 by default. These are automatically collected events and enhanced measurement events.
The other 2 event types require more work on the part of the user to set up. These are recommended events and custom events.
Here are the major events likely to be of use to ecommerce websites, sorted into these 4 categories.
Automatically collected ecommerce events
As the name implies, automatically collected events are automatically tracked once the initial GA4 setup has taken place. You will see data about these events without needing to take any additional steps.
Aside from foundational web tracking events such as page_view, scroll and session_start, the only automatically collected event ecommerce sites should pay particular attention to is view_search_results.
Enhanced measurement ecommerce events
Enhanced measurement events can collect additional data when specific actions are triggered. For example, these events can allow you to collect additional data on page views, scrolls and more.
For instance, tag configuration allows you to make the view_search_results event trigger for a wider array of URL query parameters than are available by default.
Recommended ecommerce events
Recommended events are commonplace events that have predefined names and parameters in GA4. This means they are relatively simple to implement in GA4.
For most sites, the majority of ecommerce tracking will take place with recommended events.
Recommended events that are likely to be of importance to an ecommerce site include
Recommended events
- login
- purchase
- refund
- search
- sign_up
- add_payment_info
- add_shipping_info
- add_to_cart
- add_to_wishlist
- begin_checkout
- remove_from_cart
- select_item
- select_promotion
- view_cart
- view_item
- view_item_list
- view_promotion
Custom ecommerce events
For highly specialised ecommerce events, you can create your custom event. Creating custom events is a far more manual process than utilising any other event type on GA4, as you need to provide custom parameters and triggers.
While custom events can be a useful way to get even more insight out of your GA4 setup, defining parameters and triggers yourself can be time-consuming and prone to user error.
As such, it’s best to rely on other kinds of events where possible.
What product data can be tracked in GA4?
When setting up ecommerce event tracking in GA4, you naturally want to get information about the products customers are buying. This helps you understand not only your best-selling products, but also popular categories, and information on how customers come across particular products.
In GA4, product data is collected in a type of parameter known as items array. For an items array to function, it requires one of the following 2 parameters to be set.
List of Parameters
For an items array to function, it requires one of the following 2 parameters to be set:
- item_id: For instance, SKU_12345.
- item_name: For instance, Camo Hoodie.
Other significant item parameters that can be set include:
- coupon: The name of a coupon associated with the item.
- discount: A monetary discount value associated with the item.
- item_brand: The brand of the item.
- item_category: Designated item categories, such as “Apparel”, “Adult”, “Hoodies”. You can have up to 5 item_category parameters in an array, organised by hierarchy.
- item_list_id: The name of the list in which the item was presented to the user, such as “related_products”.
- price: The monetary unit price of the item.
In addition to required and recommended parameters in the items array, you can also add up to 27 custom parameters.
Key ecommerce events in GA4
Let’s dive into some of the most significant recommended ecommerce events in GA4, and how you can most effectively track them.
view_item_list
This event tracks when a user is presented with a list of products on your site. For example, if they are on a product page, they may see a list of related items.
It requires an item array to function and can be modified with item_list_id and item_list_name parameters. However, these parameters are not necessary if they are set at the item level.
view_item
This event can be used to show that a customer has seen some content relating to an item. For example, if they have seen an item’s detail page, this event should fire.
It requires an item array to function. Setting a value parameter (i.e. 25.00) is generally required for useful reporting. If you set a parameter for value, it is required to set a parameter for currency (i.e. AUD).
begin_checkout
begin_checkouts events fire when users begin the checkout process by pressing the appropriate button on your site. Similarly to view_item, this event requires value and currency parameters in addition to the items array.
You can also set a coupon parameter. Note that item-level and event-level coupon parameters are separate.
add_shipping_info
This event indicates a user has added their shipping information in the checkout process. It requires value and currency parameters and an items array. Coupon parameters can also be set.
Another parameter that can be set for this event is the shipping tier. This refers to the selected form of shipping, such as air or next-day.
purchase and refund
The purchase and refund events are exactly what their names indicate. They indicate that a purchase or a refund has taken place.
Events in GA4
These 2 events rely on the same parameters:
- items array
- currency
- value
- coupon
- transaction_id: A unique string of numbers which identifies each transaction, i.e. T_12345.
- shipping: Not to be confused with shipping_tier, shipping is the monetary value associated with the transaction, i.e. 4.45.
- tax: The monetary value associated with the transaction, i.e. 3.00.
What is the GA4 ecommerce purchases report?
Once you have completed the initial GA4 setup, you can access a premade ecommerce purchases report. This report is an ideal starting point for GA4 ecommerce setup.
Dimensions and Metrics
This report includes the following dimensions:
- Item brand: Populated from the item-level item_brand parameter in an event.
- Item category: This is the first hierarchical item in which items are classified. For example, in Tech/Phones/iPhones, Tech is the first category. It is populated from the item-level item_category parameter.
- Item category 2-5: You can have up to 5 item categories in this report, each with a number corresponding to its place in the hierarchy. Item category 2 is populated by the item_category2 parameter, item category 3 by the item_category 3 parameter, and so on.
- Item ID: The specified ID for an item, populated by the item_id parameter.
- Item name: The name of the item, populated by the item_name parameter.
This report also includes the following metrics:
- Item revenue: The total revenue from items only, excluding tax and shipping.
- Items added to cart: The number of items added to the cart, populated by the items array in an add_to_cart event.
- Items purchased: The number of items purchased, populated by the items array in a purchase event.
- Items viewed: The number of items viewed, populated by the items array in a view_items event.
Complying with the GDPR and CCPA while tracking ecommerce events in GA4
While data can be exceptionally valuable for your business, it’s important to remember the risks it can pose. Data privacy regulations are in place around the globe to ensure data is safely and responsibly handled by corporations.
You must comply with data privacy regulations that are in place in any jurisdiction from which your website can be accessed. 2 key regulations are the European Union’s General Data Protection Regulation and the California Consumer Privacy Act.
When tracking ecommerce events in GA4, and in the process of operating an ecommerce site generally, personally identifiable information your business may find itself collecting includes:
- Name
- Email addresses
- Location information
- Credit card information
Some key principles to remember when handling PII are:
- PII must be stored securely and be protected from threats, both internal and external.
- The minimum amount of data for business operations should be collected.
- Customers have the right to know what data of theirs is being collected and retained by a business.
To take some of the stress out of complying with these regulations, lean on DataTrue. DataTrue’s privacy and compliance tool set includes sensitive data leak alerts which let you know if you’re at risk of sharing PII.
You can also rely on cookie policy audits to ensure your business is complying with regulations across the board.
Improve your ecommerce reporting with DataTrue
When you go through the lengthy process of optimising your GA4 setup for your ecommerce site, you want to ensure you are collecting the best possible data. For that, rely on DataTrue.
DataTrue’s automated data layer testing ensures this all-important part of your setup is working properly. DataTrue also offers a range of tag audit tools to ensure each and every one is functioning as intended.
In addition, you can take advantage of web analytics testing features such as simulation tests, coverage tests and validation maps. Book your DataTrue demo today and elevate your ecommerce tracking process.