[UPDATE 30th April 2021 – bonus video at the end of this article]
As you probably know, the new version of Google Analytics has now the final name of Google Analytics 4 (previously it was called App + Web).
In this guide I will explain to you how to configure an E-commerce for tracking with Google Analytics 4, and – specifically – I will focus on how to move from the traditional Enhanced E-Commerce tracking to the new e-commerce tracking provided by Google Analytics 4 (it is no longer called “Enhanced E-commerce”, just simply “E-commerce”).
There are – at least – three good reasons to perform the switch:
In order to track E-commerce in GA4, we will use the Template I made for this purpose.
You can find it in the official Google Tag Manager Gallery at this link:
As I mentioned, GA4 is based on events. You can find the list of events managed by GA4 in the official guide:
The good news is that it is possible to reuse some of the actions present in the “traditional” Enhanced E-commerce settings (based on Google Universal Analytics) and to transform them into GA4 actions.
Let’s clarify this point. In this table you can find the GA Universal Analytics event list in Enhanced E-Commerce (EEC for friends) in the first column and the Google Analytics 4 event list in the second column:
“Ok, but what are all those colors about?”
Here we go 🙂
Now let’s go and configure everything 🙂
Import the Variable Template “EEC dataLayer Builder for GA4” You can find it in Google’s Community Template Gallery. It is easier done than said 😀
Just follow these steps:
The EEC dataLayer Builder for GA4 Template that you just imported will look like this:
Great, now we just have to use this Template to create two custom variables.
Now you will need to create two custom variables:
GA4 – Event Name has the purpose of uniquely identifying the name of the standard event to be passed to GA4 for e-commerce tracking purposes.
Here is how to do it:
Here are the step values that you will find in the image below:
GA4 – Items has the purpose of managing the object items which will contain all the information needed for GA4.
In detail, the object will manage two possible scenarios:
Thanks to the management of both these scenarios, with this variable you will always have the correct structure for Google Analytics 4 🙂
Here are the steps to follow for this configuration:
Unfortunately, the purchase and refund event must handle some parameters – seven to be precise – that are outside the object items.
In detail, the seven parameters to be handled are:
These parameters are all contained in different positions inside the GTM dataLayer, depending on whether the dataLayer push was done for Google Universal Analytics or Google Analytics 4.
If you want to handle both the configurations (but this is a very unlikely case) then you would have to create 14 dataLayer variables in GTM.
Let’s assume that you only have to manage the dataLayer of the Enhanced Ecommerce of Google Universal Analytics (this is the first of the two scenarios that I mentioned earlier).
Let’s start by creating one Variable for each of the seven parameters.
Here’s how to do it:
The configuration should look like this:
Now you just have to repeat this operation 6 times, changing the value to red for the other variables with:
Rename all variables by adding a simple prefix: “dlv –”
This parameter is optional in Google Universal Analytics, but it is required in Google Analytics 4. If you don’t pass the currency parameter in GA4, the transaction event has some problems.
My suggestion is to check “Set Default Value” and insert “EUR” (if your e-commerce has Euro currency by default).
If your e-commerce also handles refunds, then you’d need to add an eighth variable, named
Once this is done, you should have a list like this:
In the second scenario relating to the management of GA4 events that I described above, you need to create only the variables relating to the management of GA4.
(In this case, the dataLayer push is already passing the object items.)
Consequently, the seven dataLayer variables to create are:
(In the following steps I will not consider this second scenario, and I will refer exclusively to the first scenario).
Now you just have to identify the name of the events in Google Universal Analytics (you should already have the event list if you have already implemented the Google Analytics Enhanced E-Commerce).
It all depends on how Enhanced E-commerce has been implemented, for example through modules / plugins in your CMS (WooCommerce, Prestashop, Magento, Shopify, etc), or through a custom software solution crafted by a software engineer.
[NOTE] It is possible that some pushes in the dataLayer to manage actions such as: promo impression, detail, checkout or purchase, were performed before the GTM event Container Loaded (ex Page View) and were performed without having declared the name of the event.
(By the way, if you do not declare the name of the event, you should get a slap on the wrist!)
The trick – or #barbatrucco, in Italian slang – to manage this situation (handling Message events in GTM debug) is to use GTM’s “All Pages” native trigger.
Also, if the transaction event (purchase) is done BEFORE the Container Loaded native event, then you will need to create a negative trigger and put it as exception to the Google Analytics 4 Tag which does not handle the transaction (purchase). This is because you would trigger the transaction (purchase) events two times. Don’t worry, you will see it well in step 5.
For the sake of simplicity, I will separate the actions purchase and refund from the other actions.
(I don’t think I have ever seen the action refund configured in Google Analytics).
In this example, I will use the WooCommerce implementation with the Duracell Tomi plugin.
Please note that in this example there are two actions that are not handled with a specific event:
(Duracell Tomi, you should definitely get a slap on the wrist for this!)
My intent here is to track all GA’s Enhanced E-Commerce actions excluding purchase and refund.
Here the intent is to track the purchase:
Well, it was easier than expected, wasn’t it?
Let’s move on to the Tags and we’re done 🙂
You’ve probably already created your property in Google Analytics 4 and the Data Stream of your site.
In case you have any doubts here is a small intro by Krista Seiden, who explains how to do it:
Retrieve your Google Analytics 4 code G-XXXXXXXX from your data stream.
In my case the value is: G-7CSDVRME94
Well, now let’s move on to the creation of the Tags:
The Google Analytics 4 Configuration Tag will allow us to more easily manage GA4 events in the Event Tags.
This is the last step before the final verification with debugging.
Beware of triggers. As explained before in red if not all e-commerce actions are handled by a specific event and are pushed before Container Loaded we will need to use the “All Pages” activator as well.
Also if the specific event of the transaction (in our case it will be gtm4wp.orderCompletedEEC) is pushed before the Container Loaded as in the image below:
then a universal negative trigger must be set up for the GA4 – EEC Tag.
This is the universal negative trigger for the purchase.
So you have three possible cases, obviously, you will have to choose the one that best suits your situation:
My case (that of Woocommerce) is case A
Now I am going to create the Tag for the action purchase because, as I mentioned before, I need to pass the seven additional parameters.
Activate the Google Tag Manager Debug Preview and check if the Tags are activated and if they actually manage the parameters in GA4 🙂
As you can see, product impressions are handled. Events number 3 and 4 have the tag GA4 – EEC fired:
If you click the Tag and check the Values, you can notice that both the name of the event view_item_list and the values of the items are handled correctly:
Now it’s time for the final test: let’s check if Google Analytics 4 actually receives the values.
To do this, just change the GTM code to the GA4 code on the Tag Assistant.
Now you will see all the Hit Sent in Google Analytics 4.
In detail, I have the values 3, 4, and 5 which correspond to the GA4 event:
What about the purchase? That works too 🙂
Go to debug of GTM and click the G-XXXXXX icon on the left-top menù. Search your purchase transaction and check if there are all transaction parameters:
Well, now you have no more excuses! You can track your e-commerce with Google Analytics 4 and start exploring all the new features of the new version of Google Analytics.
If you have any doubts or questions, please leave me a comment 😉
With my business Partner Roberto, we talked about “The GA4 Spaghetti Carbonara”. Enjoy 🙂
LUISAVIAROMA è uno dei principali fashion e-tailer di lusso al mondo, con oltre 5 milioni…
All’interno del vasto e competitivo mercato della Grande Distribuzione Organizzata (GDO), Mondo Convenienza rappresenta uno…
Se ti occupi di marketing o advertising, saprai che i funnel rappresentano il percorso che…
È stato un nuovo record per il GA4Summit: oltre 500 professionisti e professioniste del web…
Negli ultimi mesi hai notato in Google Analytics 4 un calo improvviso e inspiegabile nelle…
Se ti trovi su questa guida è perché hai compreso che solo attraverso la Data…
View Comments
Hello!
I have used your template and this guide to install GA4 ecommerce.
I noticed today that Google Tag Manager for Wordpress has a guide for GA4 where they offer their own GA4 container template:
https://gtm4wp.com/how-to-articles/how-to-setup-enhanced-ecommerce-tracking-google-analytics-4-ga4-version
Do you recommend that I switch out my template from yours to this one? What is the difference?
Thanks so much!
Hi Isabella, I recommend to use the GA4 dataLayer :) So the best way is use the native GA4 configuration without custom template :)
Let me know if it works for you.
Matteo
Buongiorno Matteo,
ho seguito passo passo la guida, ma credo ci sia qualche problema perchè non vedo nessun dato in modalità debug.
Non capisco se il data layer viene creato correttamente.
Il sito è realizzato con woocommerce, come potrei verificare dove sta il problema?
Grazie
Ciao Antonio, difficile aiutarti così. Riesci a darmi maggiori info sul gruppo di Facebook GA4 Italia: https://www.facebook.com/groups/337447218293900
Buon GA4!
Thanks so much for doing this guide, Matteo. It's been a huge help to me. I have it mostly working, I see the purchase events, and the items on the order....but in "Monetization" the "Total Revenue", "E-Commerce Revenue" and "Item Revenue" is always 0.00
In "realtime" I can see the purchase event has a value. I'm not sure how to debug the 0.00 values. Do you happen to have any ideas?
Thanks again!
Hey Rory, did you check the currency parameters? It's a mandatory if you want to see the revenue on GA4.
Let me know.
Hi Matteo,
Do you know why events like view_item and add_to_cart are doubled inside GTM Server Side? I am using this tag to send events further to GTM Server Side.
All config inside standard GTM looks fine. Just one event like add_to_card is being fired, but two are visible inside GTM Server Side. All other tested activity like page_view, select_item, select_item_lists works like a charm.
Any clue?
Hi Peter, I will check it and I will send an email :)
Thank you!
Thank you for the detailed and comprehensive nature of this material. I would have lost the train of thought without your specificity on each step. Google should pay you to develop "how to" resources for them.
Hi John! Thank you very much for this feedback.
Actually, I'm an official beta tester of GTM ;)
Hello Matteo,
Thanks for this tutorial. It's amazing. I have an issue.
The event parameter "Items" not work on GA4 configuration purchase Tag. It shows a value {{Objetct}} and not the name of product.
Take a look on images.
https://imgur.com/RkdLKMY
https://imgur.com/euxqL3M
https://imgur.com/W0tJ5X5
https://imgur.com/kd9RFFp
Hi Cesar, could you share the configuration of the purchase tag?
This is the configuration:
Let me know :)
Hi Matteo,
Thank you so much for the clear explanation. I have one problem. When I test Case A, there are no tracked conversions. When I use Case B or C, the conversions are tracked double.
Some screens: https://1drv.ms/u/s!AieHhpISGzhzhG01BEY0QxDMpxEY?e=kEsdm9
Shop: https://sioux.shopping.nl/
Hi Niels, you need to set up the exception trigger purchase in the GA EEC tag. Make sure the purchase event still exists.
Let me know if it works
Hi Matteo, first of all thanks from The Netherlands for the awesome tutorial and template. I can't imagine how much work this have costs you, so I'm very glad you helped us all with this!
I've walked trough all steps and everythings seems to work perfectly. I only don't see any ecommerce value on the overview page: https://dsc.cloud/4f0660/Screen-Shot-2021-03-10-10-07-19.06.png. But when I look under ecommerce purchases I do see the value and the products which are bought: https://dsc.cloud/4f0660/Screen-Shot-2021-03-10-10-08-36.30.png.
Is this a setting in Google Analytics or am I missing something? :)
Thanks already for your reply mate!
Ciao Ciao,
Nick
Hi Nick and thank you for your feedback. Did you check the GA4 parameters in the GTM debug mode?
Did you see these parameters?
Please, be careful about ecommerce.currencyCode.
Let me know.
Hello Matteo,
Thanks for this fantastic guide! I was used to Universal analytics and I must admit that the switch to GA4 is tough ... Thanks to your guide everything is working perfectly!
I just have a small problem, I'm trying to bring up the add to cart event in analytics. Does your variable do this automatically or do I need to create a new one?
Basically, I only view items and purchase on alytics right now. I tried by following other guides to create a new add to cart variable in addition: https://prnt.sc/10ed7uw
Also, it seems that I should add an event on GA4 to display it, it is not included in the base? I did not find anything on the subject here is what I added:
https://prnt.sc/10ed8zb
Thank you very much !
Hi Timothe, you don't implement a specific Tag for add_to_cart, because all parameters are in the object "items" and it's ok with my template variable (step 5).
Could you share URL of your ecommerce?
Thank you!
Hi Matteo,
Great article, thanks. I have implemnted all the steps, but in preview I am not seeing any of the Custom Events. I can see that tags are firing as they should, but not custom events. No errors showing though, which is good. I am using WooCommerce and so wnet with case 3 with the negative tag. Thanks.
Hi Hugh and thanks.
Ok, are you sure the Universal Analytics Enhanced E-Commerce is set up? Could you share the URL or some screenshots?
Thanks