When you have the business online and want to see its revenue, you need to set up ecommerce tracking in Google Analytics 4. As Peter Drucker said, “You can’t improve what you don’t measure.” It suits our case too. If you can’t see the revenue in GA4, you won’t be able to increase it. However, before increasing it, let’s figure out what e-commerce tracking means and why you should consider enabling it. 

What’s ecommerce tracking, and why do you need it?

Ecommerce tracking is a feature in Google Analytics 4 that allows you to measure the purchase behaviour of your clients. Such as purchases, refunds, items viewed, etc. 

The data from e-commerce tracking is crucial to answering the following questions:

  1. What products do clients buy more often?
  2. How much revenue does the specific promotion generate?
  3. How many clients does your affiliate bring weekly?
  4. How many clients do make a refund after making a purchase, and why do they make it?
  5. What clients do have a higher-order value?
  6. How many clients do make the second, third, etc. order on your website?

and many more.

Answering these questions helps companies to boost revenue and improve the number of clients. However, it is up to you to decide if you want to answer all or only questions related to purchases. Therefore, GA offers two solutions: basic and enhanced ecommerce tracking. 

What does enhanced ecommerce tracking mean?

The basic ecommerce tracking allows you to see only the purchase data. The enhanced ecommerce tracking enables you to track a few additional steps, such as:

  1. product listing views
  2. product selection
  3. product views
  4. adding the product to the cart
  5. adding the product to the wishlist
  6. viewing the cart
  7. removing from the cart
  8. making a purchase
  9. making a refund
  10. all checkout process steps
  11. promotions views and clicks on them

Although enhanced ecommerce tracking can look complicated and heavy to implement, it brings additional benefits when you analyse your promotion or marketing campaigns deeply. In this guide, I will explain how to implement each separately. However, remember that you should be upgraded from Universal Analytics to Google Analytics 4 before moving with the following steps. The first step of the implementation is to understand how different GA4 e-commerce tracking from Universal Analytics. You can miss the next section if you don’t have a Universal Analytics account. 

What are the differences between UA ecommerce tracking and GA4 ecommerce tracking?

Although there are not so many changes in Google Analytics 4 compared to Universal Analytics regarding ecommerce tracking, if you don’t write your code right, the data won’t be sent into GA4. I summarised the main differences between ecommerce events in the table below. Ecommerce events trigger the specific action a user makes on your website, such as purchase, add to cart or make a refund. 

UA Event

GA4  Event

Description

view_item_list

impressions

For listing pages when a user is presented with the results.

productClick

select_item

Whenever a user selects the product in the list of products (listing)

detail

view_item

Whenever a user sees the detail of the product (product page)

addToCart

add_to_cart

Whenever a user adds the product into the cart.

removeFromCart

remove_from_cart

Whenever a user removes the product from the cart

N/A

add_to_wishlist

Whenever a user adds the product into wishlist. The new event added in GA4.

N/A

view_cart

Whenever a user opens the cart. The new event added in GA4.

checkout

begin_checkout

Whenever a user goes through the checkout steps. You could define steps in UA, GA4 has default steps you should follow.

checkout_option

add_shipping_info, add_payment_info

Whenever a user adds shipping or payment info within the checkout process

purchase

purchase

Whenever a user makes a purchase

refund

refund

Whenever a user requests a refund

view_promotion

promoView

Whenever a user sees the promo on your website

select_promotion

promoClick

Whenever a user selects the promo on your website

Apart from the ecommerce events, Google also changed the ecommerce events parameters. Below I will show you the difference in the main event “Purchase”, if you want to activate Enhanced Ecommerce,  I highly recommend you to visit the official google documentation. Moreover, if you want to keep both analytics (UA and GA) active, you will need to trigger two data layers. 

Purchase Information

UA

GA4

Description

currency

currency

USD, EUR, etc

id

transaction_id

The unique id of the transaction

revenue

value

The monetary value of the purchase event (revenue)

tax

tax

The monetary value of tax

shipping

shipping

Shipping costs

affiliation

affiliation

Affiliation

coupon

coupon

The coupon used with the transaction.

Product Information associated with Purchase

UA

GA4

Description

id

item_id

ID of the product.

name

item_name

The product name.

coupon

coupon

The coupon used for the purchase.

brand

item_brand

The brand of the product.

category

item_category, item_category2, item_category3, item_category4, item_category5

The category of the product.

variant

item_variant

The variant of the product. For instance, blue.

price

price

The product price.

quantity

quantity

The quantity a use bought.

position

index

The product position in the list.

list

item_list_id

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

N/A

item_list_name

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

N/A

discount

The discount a user got.

N/A

affiliation

The affiliation for the product.

N/A

location_id

The physical location associated with the product.

From the data above, you can see that the names of the parameters changed. Besides that, Google also added new product parameters that you can use to investigate sales more carefully. For instance, location_id and discount.  

Now when we discussed the differences between UA and GA4 ecommerce tracking, let’s delve deeper into the implementation. 

How to set up ecommerce tracking on your website? 

The process of setting up GA4 ecommerce tracking through GTM consists of the following steps:

  1. Ask your engineering team to add the data layer purchase code on your website according to the official google documentation.

  2. Create the new trigger of “custom event” type in Google Tag Manager “purchase”. 

  3. Name it “Custom Event – GA4 purchase” and save it.

  4. Create the GTM data layer variables to track purchase information and save them. 

  5. Create the new tag of “Google Analytics: GA4 Event” type and select the configuration tag.

  6. Write “purchase” in “Event Name” field. 

  7. Write the event parameters and select their values using the GTM variables you created early.

  8. Name the tag “GA4 – eCommerce Purchase Tracking” and save it.

  9. Make a test purchase and check your event in GTM Preview and GA4 Realtime Report.

  10. Publish the GTM container.

The above steps are used for basic and enhanced ecommerce tracking. Let’s discuss how to implement basic ecommerce tracking implementation in detail. 

How to set up ecommerce tracking in Google Analytics 4 using Google Tag Manager?

Imagine that your devs added the code below (purchase event) to your website. Now you want to set up GTM to transfer this data into Google Analytics 4 to use basic ecommerce tracking (only purchase data). 

dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "purchase",
  ecommerce: {
      transaction_id: "T_12345",
      affiliation: "Google Merchandise Store",
      value: 25.42,
      tax: 4.90,
      shipping: 5.99,
      currency: "USD",
      coupon: "SUMMER_SALE",
      items: [
       {
        item_id: "SKU_12345",
        item_name: "Stan and Friends Tee",
        affiliation: "Google Merchandise Store",
        coupon: "SUMMER_FUN",
        currency: "USD",
        discount: 2.22,
        index: 0,
        item_brand: "Google",
        item_category: "Apparel",
        item_category2: "Adult",
        item_category3: "Shirts",
        item_category4: "Crew",
        item_category5: "Short sleeve",
        item_list_id: "related_products",
        item_list_name: "Related Products",
        item_variant: "green",
        location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
        price: 9.99,
        quantity: 1
      }]
  }
});

Here are the steps you should take to implement it right.

GTM-showing-purchase-trigger
“custom event – purchase” GTM trigger

Step #1: Open GTM and create a new trigger. Let’s name it “custom event – purchase”.

Step #2: Write “purchase” in the “Event name” field and save the tag. 

GTM-showing-Ecommerce-Items-Variable
“Ecommerce Items” variable

Step #3: Open the Create the data layer variables to track purchase and product information. For instance, I created “Ecommerce – Transaction ID” data layer variable with “order_id” as the Data Layer Variable Name. I made the same for items, transaction_id, affiliation, value, tax, shipping, currency, coupon.

For “Ecommerce – Items” variable, I used “ecommerce.items”. It helps you to track the product information that a user bought without proving every product parameter. 

After you have created all variables, save them.

GTM-showing-purchase-tag-setup
“Purchase” Tag complete setup

Step #4: Go to the “Tags” section in GTM and create a new tag. Name it “GA4 – eCommerce Purchase Tracking”.

Select the GA4 configuration tag and write “purchase” to the “Event Name” field.

Step #5: Open the “Event Parameters” section and provide the ecommerce parameters using the data layer variables you created in Step #3. All in all, you should get close to what you see in my screenshot below. Save the tag. 

Step #6: Complete a test purchase to check if ecommerce tracking is working well.  Open GTM Preview Mode, go through the checkout process and check if you see in GTM Tag Assistant Tab your tag. After that, open GA4 Realtime report and check if GA4 received “purchase” event. 

Step #7: Publish GTM container.

How to set up enhanced ecommerce tracking in Google Analytics 4 using Google Tag Manager?

The process of setting up enhanced ecommerce tracking in GA4 through GTM looks almost the same as what we did in the previous section with the purchase event. The main difference is that you should set up more events to track (add to cart, refund, impressions, view_item, view_cart and so on). More events mean more data layer variables in GTM to get the necessary ecommerce parameters. Let me show you an example of the “begin_checkout” event.

Imagine that the devs added the following code to your website. 

dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "begin_checkout",
  ecommerce: {
    items: [
    {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      affiliation: "Google Merchandise Store",
      coupon: "SUMMER_FUN",
      currency: "USD",
      discount: 2.22,
      index: 0,
      item_brand: "Google",
      item_category: "Apparel",
      item_category2: "Adult",
      item_category3: "Shirts",
      item_category4: "Crew",
      item_category5: "Short sleeve",
      item_list_id: "related_products",
      item_list_name: "Related Products",
      item_variant: "green",
      location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
      price: 9.99,
      quantity: 1
    }
    ]
  }
});

If you compare the code above with the purchase code in the previous section, you will see that the line with the event is different. 

While the purchase event has “purchase”, the checkout event has “begin_checkout”. Taking into account this difference, the process of begin_checkout implementation will have the following steps:

GTM-showing-begin-checkout-trigger
GTM trigger “begin_checkout”

Step #1: Open GTM and create a new trigger. Let’s name it “custom event – begin_checkout”.

Step #2: Write “begin_checkout” in the “Event name” field and save the tag. 

Step #3: Open the variables tag and create the new data layer variables to track purchase and product information. In our case, there are no new variables. We can miss it. 

Showing-GA4-Enhanced-Ecommerce-Tag
“GA4 – eCommerce Enhanced – Begin Checkout” GTM Tag

Step #4: Go to the “Tags” section in GTM and create a new tag. Name it “GA4 – eCommerce Enhanced – Begin Checkout”.

Select the GA4 configuration tag and write “begin_checkout” to the “Event Name” field. 

Step #5: Open the “Event Parameters” section and provide the ecommerce parameters using the data layer variables you created in Step #3. All in all, you should get close to what you see in my screenshot below. Save the tag. 

Step #6: Complete a test purchase to check if ecommerce tracking is working well. 

Step #7: Publish GTM container.

How to set up ecommerce tracking in Google Analytics 4 using GTAG.js?

If you used GTAG.js for Universal Analytics, you can use it for GA4 as well. You can read more on how to upgrade from UA to GA4 using GTAG.js in my other article. Here I will show you a few examples of how to set up basic and enhanced ecommerce tracking for GA4 using GTAG.js code. 

Below you can see an example of a purchase event with a global tag. You can see that it doesn’t differ from what we used with GTM at all. 

gtag("event", "purchase", {
    transaction_id: "T_12345",
    affiliation: "Google Merchandise Store",
    value: 25.42,
    tax: 4.90,
    shipping: 5.99,
    currency: "USD",
    coupon: "SUMMER_SALE",
    items: [
     {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      affiliation: "Google Merchandise Store",
      coupon: "SUMMER_FUN",
      currency: "USD",
      discount: 2.22,
      index: 0,
      item_brand: "Google",
      item_category: "Apparel",
      item_category2: "Adult",
      item_category3: "Shirts",
      item_category4: "Crew",
      item_category5: "Short sleeve",
      item_list_id: "related_products",
      item_list_name: "Related Products",
      item_variant: "green",
      location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
      price: 9.99,
      quantity: 1
    }]
});

If you use gtag.js for Universal Analytics at the moment and want to send data into GA4. You should adjust it slightly to follow the new schema.

From this schema.

gtag('event', 'purchase', {
  "transaction_id": "24.031608523954162",
  "affiliation": "Google online store",
  "currency": "USD",
  "shipping": 7.50,
  "tax": 1.80,
  "value": 33.30,
  "items": [
    {
      "id": "P12345",
      "name": "Android Warhol T-Shirt",
      "brand": "Google",
      "category": "Apparel/T-Shirts",
      "variant": "Black",
      "list_name": "Search Results",
      "list_position": 1,
      "quantity": 2,
      "price": 12.00
    }
  ]
});

To this new schema.

gtag('event', 'purchase', {
  "send_to": "GA4",
  "transaction_id": "24.031608523954162",
  "affiliation": "Google online store",
  "currency": "USD",
  "shipping": 7.50,
  "tax": 1.80,
  "value": 33.30,
  "items": [
    {
      "item_id": "P12345",
      "item_name": "Android Warhol T-Shirt",
      "item_brand": "Google",
      "item_category": "Apparel/T-Shirts",
      "item_variant": "Black",
      "quantity": 2,
      "price": 12.00
    }
  ],
});

You can see that the main differences are the new type of product parameters we discussed in the section “What are the differences between UA ecommerce tracking and GA4 ecommerce tracking?” of this article and one more line of the code “”send_to”: “GA4””.

If you want to upgrade your enhanced UA ecommerce codes to GA4 ecommerce codes. You will need to review the google official documentation to read more about it.

For instance, if you had this schema to send “view_item_list” data into Universal Analytics.

gtag('event', 'view_item_list', {
  "items": [
    {
      "id": "P12345",
      "name": "Android Warhol T-Shirt",
      "list_name": "Search Results",
      "brand": "Google",
      "category": "Apparel/T-Shirts",
      "variant": "Black",
      "list_position": 1,
      "quantity": 2,
      "price": 2
    },
    {
      "id": "P67890",
      "name": "Flame challenge TShirt",
      "list_name": "Search Results",
      "brand": "MyBrand",
      "category": "Apparel/T-Shirts",
      "variant": "Red",
      "list_position": 2,
      "quantity": 1,
      "price": 3
    }
  ]
});

You will need to update that schema to this one.

gtag("event", "view_item_list", {
  "send_to": "GA4",
  item_list_id: "related_products",
  item_list_name: "Related products",
  items: [
    {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      affiliation: "Google Merchandise Store",
      coupon: "SUMMER_FUN",
      currency: "USD",
      discount: 2.22,
      index: 0,
      item_brand: "Google",
      item_category: "Apparel",
      item_category2: "Adult",
      item_category3: "Shirts",
      item_category4: "Crew",
      item_category5: "Short sleeve",
      item_list_id: "related_products",
      item_list_name: "Related Products",
      item_variant: "green",
      location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
      price: 9.99,
      quantity: 1
    }
  ]
});

You see that the idea is the same. You can have more parameters, and you should follow their new schema.

Final Words

GA4 ecommerce tracking is a precious feature for many companies. There are two ecommerce trackings: basic and enhanced. You can select the most suitable variant and implement it using the guide mentioned in this article. If you got stuck in the process, let me know in the comment section below, and I will be happy to assist you. You can also message me using the contact form on my website. 


What is e-commerce tracking in Google Analytics 4?

Ecommerce tracking is a feature in Google Analytics 4 that allows you to measure the purchase behaviour of your clients. Such as purchases, refunds, items viewed, etc.

How do I set up ecommerce tracking in Google Analytics 4?

In order to set up GA4 ecommerce tracking, you should follow the following steps:
Step #1: Ask your engineering team to add the data layer purchase code on your website according to the official google documentation.
Step #2: Create the new trigger of “custom event” type in Google Tag Manager “purchase”. 
Step #3: Name it “Custom Event – GA4 purchase” and save it.
Step #4: Create the GTM data layer variables to track purchase information and save them. 
Step #5: Create the new tag of “Google Analytics: GA4 Event” type and select the configuration tag.
Step #6: Write “purchase” in “Event Name” field. 
Step #7: Write the event parameters and select their values using the GTM variables you created early.
Step #8: Name the tag “GA4 – eCommerce Purchase Tracking” and save it.
Step #9: Make a test purchase and check your event in GTM Preview and GA4 Realtime Report.
Step #10: Publish the GTM container.

How do I set up a purchase event in Google Analytics?

If you want to set up a purchase event in GA4, you should set up ecommerce tracking for your website. You can learn more about that by reading this article. 

What is enhanced ecommerce in Google Analytics 4?

The basic ecommerce tracking allows you to see only the purchase data. The enhanced ecommerce tracking enables you to measure a few additional steps, such as:
1. product listing views
2. product selection
3. product views
4. adding the product to the cart
5. adding the product to the wishlist
6. viewing the cart
7. removing from the cart
8. making a purchase
9. making a refund
10. all checkout process steps
11. promotions views and clicks on them

Does GA4 support enhanced ecommerce?

Yes, you can use enhanced ecommerce tracking with GA4. 

How do I enable enhanced ecommerce in Google Analytics 4?

The process of setting up enhanced ecommerce tracking in GA4 through GTM looks close to the process of setting up a purchase event. The main difference is that you should set up more events to track (add to cart, refund, impressions, view_item, view_cart and so on). More events mean more data layer variables in GTM to get the necessary ecommerce parameters.

Written By

Ihar Vakulski

With over 8 years of experience working with SaaS, iGaming, and eCommerce companies, Ihar shares expert insights on building and scaling businesses for sustainable growth and success.

KEEP LEARNING
Leave a Comment

Your email address will not be published. Required fields are marked *

[custom_comment_form]