I often hear clients ask, “Can I create a GA4 ecommerce object from the one I use for Universal Analytics (UA)?”
The answer is that you can! This article shows you how to do this easily.
Importantnote: Make sure to set up the GA4 dataLayer properly by July 2023.
Let me first show you a couple of pictures for reference.
This is the UA ecommerce object:
And this is the GA4 ecommerce object:
Apart from the additions of various other variables like item category types and list types, the names of the variables are also changed in GA4. Thus, it is not just a simple job of capturing the data as a dataLayer variable in Google Tag Manager (GTM) and passing it on with the GA4 purchase tag.
It is relatively simple to get “transaction_id” from the older “id” by creating a dataLayer variable called “dlv – transactionId” from the dataLayer using the string “ecommerce.purchase.actionField.id”.
We can do similar dataLayer pickups for value, tax, currency, etc.
But what does one do to capture the items array from the products array? That is the part where people usually get stumped.
Let me show you.