Understanding Google Analytics 4 ecommerce tracking

In this article, I am going to show you how to set up ecommerce tracking in Google Analytics 4 (GA4) using Google Tag Manager (GTM).

With Google Analytics 4 properties, ecommerce implementation is a bit different compared to the legacy version, also known as Universal Analytics. I recommend following the developer’s documentation Ecommerce (GA4) Developer Guide alongside this article.

If we compare Google Analytics 4 vs Universal Analytics there are a few similarities and differences, as below.

1) Schema changes

While setting up the ecommerce events we need to pass the different schemas like product details, currency, promotions, etc.

Just to give you an example, earlier in Universal Analytics if we wanted to pass product name, we used to pass it using ‘name’ but in case of GA4 it is just ‘item_name’.

Another example, if you wanted to measure a promotion (when a user clicks on any promotion link), in universal analytics we use to pass this using ‘promoClick’ but in the case of GA4, it has now changed to ‘select_promotion’.

The table below will provide you with details on the different schemas and changes.

NoGoogle
Analytics 4
Universal AnalyticsDescription
1view_promotionpromoViewWhen a user views a promotion
2select_promotionpromoClickWhen a user clicks on a promotion
3view_item_listimpressionsView of product impressions in a list
4select_itemproductClickClick on a product
5view_itemdetailView product details
6add_to_cartaddToCartAdd product to cart
7add_to_wishlistN/AAdd product to a wishlist
8remove_from_cartremoveFromCartRemove product from the cart
9view_cartN/AView shopping cart
10begin_checkoutcheckoutInitiate the checkout process
11add_shipping_infocheckout_optionAdd shipping info during the checkout
12add_payment_infocheckout_optionAdd payment info during the checkout
13purchasepurchasePurchase product
14refundrefundRefund product
15item_ididProduct ID / SKU
16item_namenameName of the product
17item_list_namelistProduct list name
18item_list_idN/AProduct list identifier
19indexpositionProduct position in the list
20item_brandbrandProduct brand
21item_categorycategoryProduct category
22item_category_2categoryProduct category 2nd level
23item_category_3categoryProduct category 3rd level
24item_category_4categoryProduct category 4th level
25item_category_5categoryProduct category 5th level
26item_variantvariantProduct variant name or description
27affiliationN/AThe store affiliation
28discountN/AAny discount on product
29couponcouponCoupon code used
30pricepriceProduct price
31currencyN/AUser currency
32quantityquantityProduct quantity
33promotion_ididPromotion ID
34promotion_namenamePromotion name
35transaction_ididUnique ID for the transaction required for purchase and refund events
36valuerevenueProduct revenue
37shippingshippingShipping charges for selected product in cart
38payment_typeoptionThe payment method sent with add_payment_info

2) Data layer implementation

You might be thinking to update your data layer according to the new schemas, but wait!

If you are using Universal Analytics for your ecommerce website do not update your current set up.

The reason behind this is the new schemas are not backwards compatible and hence can break your current (Universal Analytics) set up.

The good news is that for the majority of the schemas they are forward compatible and Google will translate your Universal Analytics events to the GA4 App + Web custom events.

The best thing to do to keep both versions of analytics active and running is to update your current set up to add GA4 App + Web specific dataLayer and schemas along with current schemas. This way it won’t break your Universal Analytics and the GA4 App + Web will also have its required schemas.

Now let’s get started with setting up ecommerce tracking in Google Analytics 4

Setting up ecommerce tracking in Google Analytics 4 using Google Tag Manager

Note: Ecommerce events can be also implemented using global site tag (gtag.js). In our case, we will be using Google Tag Manager.

While implementing the ecommerce tracking, we need to define or modify our DataLayer on the page and this needs development work to update the values.

If you are not familiar with the dev work you can ask your developer to carry out DataLayer implementation. Once the DataLayer is defined you can configure the DataLayer variable in GTM.

Follow the below steps to create an ecommerce DataLayer variable.

Step 1: Log in to your Google Tag Manager console and click on ‘Variables’ in the left-hand side menu.

Google Tag Manager<variables

Step 2: Click on ‘New’.

GTM<NEW

Step 3: Give a proper name to your variable and click on ‘Variable Configuration’.

Variable configuration

Step 4: An overlay will appear like below. Select the Data Layer variable.

The data layer variable

Step 5: Variable configuration will open like below. Type ‘ecommerce.items’ as the Data Layer variable name.

Ecommerce items

Step 6: Click on ‘Save’.

save

Since our Data Layer variable is configured, we can proceed with implementing ecommerce events. We will be measuring the standard ecommerce events.

The below section will provide you details of DataLayer code, GTM tag configuration and trigger condition.

1. Product/item list views/impressions

This event will measure product impressions. We need to fire this tag on the pages where a list of products is displayed, generally on the home page, category pages, etc.

DataLayer configuration:

To measure item list views/impressions, we need to push a list of products and their attributes to the data layer and pass a ‘view_item_list’ event along with that data.

// Measure product views / impressions

dataLayer.push({

‘event’: ‘view_item_list’,

‘ecommerce’: {

‘items’: [

{

‘item_name’: ‘Sample Product 1’,       // Product Name- Type: String

‘item_id’: ‘123456’,                       // Product ID/SKU- Type: String

‘price’: ‘35.25’,                     // Product price – Type: numeric

‘item_brand’: ‘Your Brand Name’,           //Product brand – Type: string

‘item_category’: ‘Category Name’,     // Product category Main – Type: string

‘item_category_2’: ‘Category level1’, // Product category (Mens, Kids) – Type: string

‘item_category_3’: ‘Category level2’, // Product category (Shirts, Shoes) – Type: string

‘item_category_4’: ‘Category level3’, // Product category (T-shirt, Sport Shoes) – Type: string

‘item_variant’: ‘Variant’,          // Variant of the product like color, size etc – Type: string

‘item_list_name’: ‘Search Results’,     // Product List Name – Type: string

‘item_list_id’: ‘SR12’,                        // Product List ID – Type: string

‘index’: 1,                               // Product List Position – Type: Numeric

‘quantity’: ‘1’                                     // Product quantity – Type: numeric

}]

}

});

Google tag configuration:

Once the above code is pushed to the DataLayer, the next step is to configure your tag. Follow the below steps to configure.

Step 1: Log in to your Google Tag Manager console and click on ‘Tags’ in the left-hand side menu.

Google Tag Confiugration<tags

Step 2: Click on ‘New’ to create a new scroll event tag for the GA4 property.

GA4 property<new

Step 3: Give a proper name to your tag and click on ‘Tag Configuration’.

Tag configuration2

Step 4: An overlay will appear at the right-hand side with a list of tag templates. Select ‘Google Analytics: GA4 Event’.

Google Analytics:GA4 Event

Step 5: Tag configuration window will open like below. Click on ‘Select Configuration Tag’.

select configuration tag

Step 6: A drop-down menu will appear. You can either select your pageview tag or ‘None- Manually Set ID’ from the drop-down. In our case, we will select  ‘None- Manually Set ID’.

None_manually set id

Step 7: The next step is to enter the GA measurement ID in the input box.

You can find your measurement ID in the admin section under ‘Data Streams’.

Data stream

Google Analytics :GA4Event<measurement id

Step 8: Specify the name of the event. Event name you provide here will appear in you GA4 analytics reporting. Now give an event name as ‘view_item_list’.

View_item_list

Step 9: Click on the ‘Event Parameters’ drop-down menu:

Event_parameter

Step 10: Click on the ‘Add Row’ button:

Add row

You should now see the two new text boxes: ‘Parameter Name’ and ‘Value’.

Step 11: Type ‘items’ in the ‘Parameter Name’ text box.

Parameter name and value

Step 12: Click on the ‘+’ button under the ‘Value’ text box:

+<value box

Step 13: An overlay will appear like below. Select ‘GA 4 Ecommerce DataLayer’ variable. This the same variable that we created earlier.

GA4 Ecommerce data layer

Step 14: Your tag configuration will appear like below.

Tag configuration apperance

It’s done! Now let’s set up the trigger configuration.

Trigger Configuration:

Step 15: Click anywhere under ‘Triggering’.

Trigger configuration

Step 16: An overlay will appear like below. Click on the ‘+’ icon to add a new trigger.

+<new trigger

Step 17: Give a proper name to your trigger and click anywhere in ‘Trigger Configuration’.

Trigger configuration02

Step 18: An overlay will appear like below. Select ‘Custom Event’ from the list.

Custom event

Step 19: ‘Trigger Configuration’ will open. In the input box, we need to provide the event name. In this event, it is ‘view_item_list’ since we are measuring product impressions. Type ‘view_item_list’ In the event name.

View_item_list

Step 20: Click on ‘Save’.

Save

Your complete tag will look like below.

Google Analytics:GA4Events11

Congratulations!!! You have successfully created your first ecommerce event for your GA4 property. Now let’s do this for the remaining ecommerce events.

Since I already showed you the step-by-step method to create it in the above event, for the other events I will now only show you the DataLayer code, and final tag configuration and trigger configuration.

2. Product/item list clicks

DataLayer configuration:

To measure product clicks, we need to push the product and its attributes to the data layer and pass a ‘select_item’ event along with that data.

// Measure product Clicks

dataLayer.push({

‘event’: ‘select_item’,

‘ecommerce’: {

‘items’: [

{

‘item_name’: ‘Sample Product 1’,       // Product Name- Type: String

‘item_id’: ‘123456’,                       // Product ID/SKU- Type: String

‘price’: ‘35.25’,                     // Product price – Type: numeric

‘item_brand’: ‘Your Brand Name’,           //Product brand – Type: string

‘item_category’: ‘Category Name’,     // Product category Main – Type: string

‘item_category_2’: ‘Category level1’, // Product category (Mens, Kids) – Type: string

‘item_category_3’: ‘Category level2’, // Product category (Shirts, Shoes) – Type: string

‘item_category_4’: ‘Category level3’, // Product category (T-shirt, Sport Shoes) – Type: string

‘item_variant’: ‘Variant’,          // Variant of the product like color, size etc – Type: string

‘item_list_name’: ‘Search Results’,     // Product List Name – Type: string

‘item_list_id’: ‘SR12’,                        // Product List ID – Type: string

‘index’: 1,                               // Product List Position – Type: Numeric

‘quantity’: ‘1’                                     // Product quantity – Type: numeric

}]

}

});

Google tag configuration:

Once the above code is pushed to the DataLayer, you can configure your Google Tag Manager tag like below.

  • Tag type: GA4 Event
  • Event name: select_item
  • Event parameter (name – value): ‘items’ – {{Ecommerce Items}}
  • Variable type: data layer variable – ‘ecommerce.items’
Google tag configuration:< DataLayer

Trigger configuration:

You can create a trigger with below configuration

  • Trigger type: Custom event
  • Trigger condition: event equals ‘select_item’
Trigger configuration<create a trigger configuration

3. Product/item detail views

To measure product views, we need to push the product and its attributes to the data layer and pass a ‘view_item’ event along with that data.

// Measure Product Detail View

dataLayer.push({

‘event’: ‘view_item’,

‘ecommerce’: {

‘items’: [

{

‘item_name’: ‘Sample Product 1’,       // Product Name- Type: String

‘item_id’: ‘123456’,                       // Product ID/SKU- Type: String

‘price’: ‘35.25’,                     // Product price – Type: numeric

‘item_brand’: ‘Your Brand Name’,           //Product brand – Type: string

‘item_category’: ‘Category Name’,     // Product category Main – Type: string

‘item_category_2’: ‘Category level1’, // Product category (Mens, Kids) – Type: string

‘item_category_3’: ‘Category level2’, // Product category (Shirts, Shoes) – Type: string

‘item_category_4’: ‘Category level3’, // Product category (T-shirt, Sport Shoes) – Type: string

‘item_variant’: ‘Variant’,          // Variant of the product like color, size etc – Type: string

‘item_list_name’: ‘Search Results’,     // Product List Name – Type: string

‘item_list_id’: ‘SR12’,                        // Product List ID – Type: string

‘index’: 1,                               // Product List Position – Type: Numeric

‘quantity’: ‘1’                                     // Product quantity – Type: numeric

}]

}

});

Google tag configuration:

Once the above code is pushed to the DataLayer, you can configure your Google Tag Manager tag like below.

  • Tag type: GA4 Event
  • Event name: view_item
  • Event parameter (name – value): ‘items’ – {{Ecommerce Items}}
  • Variable type: data layer variable – ‘ecommerce.items’
Google tag configuration< DataLayer<ecommerce.items’

Trigger configuration:

You can create a trigger with below configuration

  • Trigger type: Custom event
  • Trigger condition: event equals ‘view_item
Trigger configuration:<view_item

4. Add to cart

To measure add to cart, we need to push the product and its attributes to the data layer and pass a ‘view_item’ event along with that data.

// Measure Add to Cart

dataLayer.push({

‘event’: ‘ add_to_cart’,

‘ecommerce’: {

‘items’: [

{

‘item_name’: ‘Sample Product 1’,       // Product Name- Type: String

‘item_id’: ‘123456’,                       // Product ID/SKU- Type: String

‘price’: ‘35.25’,                     // Product price – Type: numeric

‘item_brand’: ‘Your Brand Name’,           //Product brand – Type: string

‘item_category’: ‘Category Name’,     // Product category Main – Type: string

‘item_category_2’: ‘Category level1’, // Product category (Mens, Kids) – Type: string

‘item_category_3’: ‘Category level2’, // Product category (Shirts, Shoes) – Type: string

‘item_category_4’: ‘Category level3’, // Product category (T-shirt, Sport Shoes) – Type: string

‘item_variant’: ‘Variant’,          // Variant of the product like color, size etc – Type: string

‘item_list_name’: ‘Search Results’,     // Product List Name – Type: string

‘item_list_id’: ‘SR12’,                        // Product List ID – Type: string

‘index’: 1,                               // Product List Position – Type: Numeric

‘quantity’: ‘1’                                     // Product quantity – Type: numeric

}]

}

});

Google tag configuration:

Once the above code is pushed to the DataLayer, you can configure your Google Tag Manager tag like below.

  • Tag type: GA4 event
  • Event name: add_to_cart
  • Event parameter (name – value): ‘items’ – {{Ecommerce Items}}
  • Variable type: data layer variable – ‘ecommerce.items’
Google tag configuration:<{Ecommerce Items}}

Trigger configuration:

You can create a trigger with below configuration

  • Trigger type: Custom event
  • Trigger condition: event equals ‘add_to_cart’
Trigger configuration: add_to_cart

5. Remove from cart

To measure remove from cart, we need to push a product and its attributes to the data layer and pass a ‘remove_from_cart’ event along with that data.

// Measure Remove From Cart

dataLayer.push({

‘event’: ‘ remove_from_cart’,

‘ecommerce’: {

‘items’: [

{

‘item_name’: ‘Sample Product 1’,       // Product Name- Type: String

‘item_id’: ‘123456’,                       // Product ID/SKU- Type: String

‘price’: ‘35.25’,                     // Product price – Type: numeric

‘item_brand’: ‘Your Brand Name’,           //Product brand – Type: string

‘item_category’: ‘Category Name’,     // Product category Main – Type: string

‘item_category_2’: ‘Category level1’, // Product category (Mens, Kids) – Type: string

‘item_category_3’: ‘Category level2’, // Product category (Shirts, Shoes) – Type: string

‘item_category_4’: ‘Category level3’, // Product category (T-shirt, Sport Shoes) – Type: string

‘item_variant’: ‘Variant’,          // Variant of the product like color, size etc – Type: string

‘item_list_name’: ‘Search Results’,     // Product List Name – Type: string

‘item_list_id’: ‘SR12’,                        // Product List ID – Type: string

‘index’: 1,                               // Product List Position – Type: Numeric

‘quantity’: ‘1’                                     // Product quantity – Type: numeric

}]

}

});

Google tag configuration:

Once the above code is pushed to the DataLayer, you can configure your Google Tag Manager tag like below.

  • Tag type: GA4 event
  • Event name: remove_from_cart
  • Event parameter (name – value): ‘items’ – {{Ecommerce Items}}
  • Variable type: data layer variable – ‘ecommerce.items’
Google tag configuration:<Data Layer

Trigger configuration:

You can create a trigger with below configuration.

  • Trigger type: Custom event
  • Trigger condition: event equals ‘remove_from_cart’
Trigger configuration:<custom event

6. Promotion views/impressions

You can measure both impressions and clicks on internal site promotions. These promotions include banners displayed on the site or an offer for free shipping.

To measure promotion view details, we need to push the product and its attributes to the data layer and pass a ‘view_promotion’ event along with that data.

// Measure promotion views/impressions

dataLayer.push({

‘event’: ‘view_promotion’,

‘ecommerce’: {

‘items’: [

{

‘item_name’: ‘Sample Product 1’,       // Product Name- Type: String

‘item_id’: ‘123456’,                       // Product ID/SKU- Type: String

‘price’: ‘35.25’,                     // Product price – Type: numeric

‘item_brand’: ‘Your Brand Name’,           //Product brand – Type: string

‘item_category’: ‘Category Name’,     // Product category Main – Type: string

‘item_category_2’: ‘Category level1’, // Product category (Mens, Kids) – Type: string

‘item_category_3’: ‘Category level2’, // Product category (Shirts, Shoes) – Type: string

‘item_category_4’: ‘Category level3’, // Product category (T-shirt, Sport Shoes) – Type: string

‘item_variant’: ‘Variant’,          // Variant of the product like color, size etc – Type: string

‘promotion_id’: ‘abc123’,                   // Promotion Campaign ID – Type: Srting

‘promotion_name’: ‘summer_promo’, // Promotion Campaign Name – Type: Srting

‘creative_name’: ‘instore_suummer’,  // Promotion Creative Name – Type: Srting

‘creative_slot’: ‘1’,                   // Promotion Creative Slot – Type: Numeric

‘location_id’: ‘hero_banner’,              // Promotion Location – Type: Srting

‘index’: 1,                                // Product List Position – Type: Numeric

‘quantity’: ‘1’                                     // Product quantity – Type: numeric

}]

}

});

Google tag configuration:

Once the above code is pushed to the DataLayer, you can configure your Google Tag Manager tag like below.

  • Tag type: GA4 event
  • Event name: view_promotion
  • Event parameter (name – value): ‘items’ – {{Ecommerce Items}}
  • Variable type: data layer variable – ‘ecommerce.items’
Google tag configuration:1

Trigger configuration:

You can create a trigger with below configuration

  • Trigger type: Custom event
  • Trigger condition: event equals ‘view_promotion’

7. Promotion clicks

To measure promotion clicks details, we need to push the product and its attributes to the data layer and pass a ‘select_promotion’ event along with that data.

// Measure promotion Clicks

dataLayer.push({

‘event’: ‘ select_promotion ‘,

‘ecommerce’: {

‘items’: [

{

‘item_name’: ‘Sample Product 1’,       // Product Name- Type: String

‘item_id’: ‘123456’,                       // Product ID/SKU- Type: String

‘price’: ‘35.25’,                     // Product price – Type: numeric

‘item_brand’: ‘Your Brand Name’,           //Product brand – Type: string

‘item_category’: ‘Category Name’,     // Product category Main – Type: string

‘item_category_2’: ‘Category level1’, // Product category (Mens, Kids) – Type: string

‘item_category_3’: ‘Category level2’, // Product category (Shirts, Shoes) – Type: string

‘item_category_4’: ‘Category level3’, // Product category (T-shirt, Sport Shoes) – Type: string

‘item_variant’: ‘Variant’,          // Variant of the product like color, size etc – Type: string

‘promotion_id’: ‘abc123’,                   // Promotion Campaign ID – Type: Srting

‘promotion_name’: ‘summer_promo’, // Promotion Campaign Name – Type: Srting

‘creative_name’: ‘instore_suummer’,  // Promotion Creative Name – Type: Srting

‘creative_slot’: ‘1’,                   // Promotion Creative Slot – Type: Numeric

‘location_id’: ‘hero_banner’,              // Promotion Location – Type: Srting

‘index’: 1,                               // Product List Position – Type: Numeric

‘quantity’: ‘1’                                     // Product quantity – Type: numeric

}]

}

});

Google tag configuration:

Once the above code is pushed to the DataLayer, you can configure your Google Tag Manager tag like below.

  • Tag type: GA4 Event
  • Event name: select_promotion
  • Event parameter (name – value): ‘items’ – {{Ecommerce Items}}
  • Variable type: data layer variable – ‘ecommerce.items’

Trigger configuration:

You can create a trigger with below configuration

  • Trigger type: Custom event
  • Trigger condition: event equals ‘select_promotion’

8. Checkouts

To measure checkout activity details, we need to push a product and its attributes to the data layer and pass a ‘begin_checkout’ event along with that data.

// Measure a Checkout

dataLayer.push({

‘event’: ‘ begin_checkout’,

‘ecommerce’: {

‘items’: [

{

‘item_name’: ‘Sample Product 1’,       // Product Name- Type: String

‘item_id’: ‘123456’,                       // Product ID/SKU- Type: String

‘price’: ‘35.25’,                     // Product price – Type: numeric

‘item_brand’: ‘Your Brand Name’,           //Product brand – Type: string

‘item_category’: ‘Category Name’,     // Product category Main – Type: string

‘item_category_2’: ‘Category level1’, // Product category (Mens, Kids) – Type: string

‘item_category_3’: ‘Category level2’, // Product category (Shirts, Shoes) – Type: string

‘item_category_4’: ‘Category level3’, // Product category (T-shirt, Sport Shoes) – Type: string

‘item_variant’: ‘Variant’,          // Variant of the product like color, size etc – Type: string

‘index’: 1,                               // Product List Position – Type: Numeric

‘quantity’: ‘1’                                     // Product quantity – Type: numeric

}]

}

});

Google tag configuration:

Once the above code is pushed to the DataLayer, you can configure your Google Tag Manager tag like below

  • Tag type: GA4 event
  • Event name: begin_checkout
  • Event parameter (name – value): ‘items’ – {{Ecommerce Items}}
  • Variable type: data layer variable – ‘ecommerce.items’

Trigger configuration:

You can create a trigger with below configuration.

  • Trigger type: Custom event
  • Trigger condition: event equals ‘begin_checkout’
Trigger configuration:

9. Purchases

To measure purchases, we need to push transactions, products and their attributes to the data layer and pass a ‘purchase’ event along with that data on thank you page.

// Measure purchases

dataLayer.push({

‘event’: ‘purchase’,

‘ecommerce’: {

‘purchase’: {

‘transaction_id’: ‘T12345’,                  // Transaction ID- Type: String

‘affiliation’: ‘Online Store’,                 // Affliation – Type: String

‘value’: ‘35.25’,                                  // Product Price- Type: Numeric

‘tax’: ‘4.90’,                              // Taxes If applicable- Type: Numeric

‘shipping’: ‘5.99’,                      // Shipping Charges- Type: Numeric

‘currency’: ‘EUR’,                     // Currency- Type: Numeric

‘coupon’: ‘SUMMER_SALE’,                      // Coupan Code if applicable- Type: String

‘items’: [

{

‘item_name’: ‘Sample Product 1’,       // Product Name- Type: String

‘item_id’: ‘123456’,                       // Product ID/SKU- Type: String

‘price’: ‘35.25’,                     // Product price – Type: numeric

‘item_brand’: ‘Your Brand Name’,           //Product brand – Type: string

‘item_category’: ‘Category Name’,     // Product category Main – Type: string

‘item_category_2’: ‘Category level1’, // Product category (Mens, Kids) – Type: string

‘item_category_3’: ‘Category level2’, // Product category (Shirts, Shoes) – Type: string

‘item_category_4’: ‘Category level3’, // Product category (T-shirt, Sport Shoes) – Type: string

‘item_variant’: ‘Variant’,          // Variant of the product like color, size etc – Type: string

‘quantity’: ‘1’                                     // Product quantity – Type: numeric

}]

}

});

Google tag configuration:

Once the above code is pushed to the DataLayer, you can configure your Google Tag Manager tag like below.

  • Tag type: GA4 event
  • Event name: purchase
  • Event parameter (name – value): ‘items’ – {{Ecommerce Items}}
  • Variable type: data layer variable – ‘ecommerce.items’
Google tag configuration:>purchase

Trigger configuration:

You can create a trigger with below configuration.

  • Trigger type: Custom event
  • Trigger condition: event equals ‘purchase’
Trigger configuration:

10. Refunds

To measure refunds, we need to push transaction details to the data layer and pass a ‘refund’ event along with that data onto the thank you page.

// Measure Refunds

dataLayer.push({

‘event’: ‘refund’,

‘ecommerce’: {

‘transaction_id’: ‘T12345’,                  // Transaction ID- Type: String

}

});

Google tag configuration:

Once the above code is pushed to the DataLayer, you can configure your Google Tag Manager tag like below.

  • Tag type: GA4 Event
  • Event name: refund
  • Event parameter (name – value): ‘items’ – {{Ecommerce Items}}
  • Variable type: data layer variable – ‘ecommerce.items’
Google tag configuration:

Trigger configuration:

You can create trigger with below configuration

  • Trigger type: Custom event
  • Trigger condition: event equals ‘refund’
Trigger configuration:

In the case that you want to measure a partial refund, you can also pass a list of products with their attributes as below.

// Measure Refunds

dataLayer.push({

‘event’: ‘refund’,

‘ecommerce’: {

‘transaction_id’: ‘T12345’,             // Transaction ID- Type: String

‘items’: [

{

‘item_name’: ‘Sample Product 1’,       // Product Name- Type: String

‘item_id’: ‘123456’,                   // Product ID/SKU- Type: String

‘price’: ‘35.25’,                // Product price – Type: numeric

‘item_brand’: ‘Your Brand Name’,       //Product brand – Type: string

‘item_category’: ‘Category Name’, // Product category Main – Type: string

‘item_category_2’: ‘Category level1’,      // Product category (Mens, Kids) – Type: string

‘item_category_3’: ‘Category level2’,      // Product category (Shirts, Shoes) – Type: string

‘item_category_4’: ‘Category level3’,      // Product category (T-shirt, Sport Shoes) – Type: string

‘item_variant’: ‘Variant’,               // Variant of the product like color, size etc – Type: string

‘quantity’: ‘1’                                // Product quantity – Type: numeric

}]

}

});

The rest of the Google Tag Manager configuration and trigger configuration will remain the same.

So, that is how you can set up ecommerce tracking in Google Analytics 4.

Ecommerce reporting in GA4

Now since you have completed the ecommerce set up for your GA4 property, you can wait for some time to generate the data and then proceed with reporting interface.

To view ecommerce reports for your GA4 property you can click on ‘Monetization’ in the reporting menu.

ecommerce<‘Monetization’

Then click on ‘Overview’.

Overview

You will get to see below trends and tables providing details like ‘Total Revenue’, ‘Total Buyers’ and ‘Avg. purchase revenue per user’.

‘Total Revenue’, ‘Total Buyers’ and ‘Avg. purchase revenue per user’.

If you want more a detailed report you can click on ‘Ecommerce Purchases’ in the reporting menu.

‘Ecommerce Purchases’ i

You will get a detailed report like below.

Ecommerce <detailed report1

Ecommerce <detailed report2

Ecommerce<detailed report3

You can also check the funnel report in the ‘Analysis’ tab by defining the funnel steps.

Note: You need to create a funnel in the analysis hub. If you are new and don’t know how to use exploration reports and funnel reports, you can check this to understand more: How to Use the Exploration Report

Ecommerce<funnel report<analysis

This how you can set up ecommerce tracking in a Google Analytics 4 property.

Leave a Reply

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