Measure ecommerce events in GA4 and Universal Analytics with only the updated datalayer pushes

A new variable in Google Tag Manager

  • Article
  • Technical Web Analytics
Anton-technical-web-analyst
Anton Bies
Technical Web Analyst
15 min
15 Nov 2021

With our variable in the Google Tag Manager Community Template Gallery it is easy to start using all the new ecommerce analytics capabilities that Google Analytics 4 offers while fully supporting the 'old' enhanced ecommerce of Universal Analytics. Find out how the variable works.

When should you adapt the data layer to GA4? 

Almost all of our customers who work with Google Analytics are switchting from Universal Analytics (UA) to Google Analytics 4 (GA4). Organisations are thus introduced to the new data model of GA. This new data model also means that new data layer pushes for ecommerce have been created.

Google has designed the model in such a way that the old enhanced ecommerce datalayer pushes can also be used for the new measurements, but that does not necessarily mean this easy solution is the best.

During the switching process, UA will logically still be the single source of truth . The ecommerce part makes it extra clear why this is also necessary for many organisations. At the time of writing this article, the new ecommerce does not support custom item parameters (product level parameters), which means that the same amount of product data cannot be collected with GA4.

For example, a company selling clothing could collect the following additional information in addition to the default dimensions for a t-shirt:

  • stock keeping unit (sku)
  • size
  • colour
  • is it for men and/or women
  • is the t-shirt still in stock
  • exactly how much stock is there
  • is the product currently on sale
  • what is the discount
  • etc.

You cannot store all this information in default parameters. That is why UA has product-scoped custom dimensions. And that's why many organisations need custom item parameters before they can fully utilise GA4 ecommerce.

Why should you already want to use the new ecommerce datalayer pushes in GA4? 

So the old enhanced ecommerce implementation still needs to be supported while you are building the new one. We see two important reasons for wanting to make use of the renewed ecommerce datalayer pushes:

  • If you are currently working on the migration, this is also the moment when the entire organisation knows change is coming.And that time must be made available for development teams to tinker with the data layer. If you wait, the momentum may pass and it will be harder to claim that time.
  • GA4 ecommerce offers new events to measure, such as view cart and add to wishlist. How are you going to measure this if you are still using the old datalayer pushes?

We previously recommended starting immediately with the GA4 implementation. Does this mean that you also need to implement ecommerce measurements? Then our advice is to immediately use the new datalayer pushes. And do you want to keep your old implementation running for now? You can do this very easily with our new variable in Google Tag Manager.

How does the variable work in Google Tag Manager? 

This custom template was developed by our colleague Anton. In the official documentation you will findall details about how it works including an extensive suggestion for use. There is also a demo page where you can see how it would work in practice if you implement that suggestion. In this article, therefore, a short summary will suffice:

GA4-ecommerce-template

If you add the template from the Community Template Gallery and then create a new variable, you can choose 'GA4 ecommerce to UA EEC' as the variable type. 

The variable does as much as possible automatically, based on the most recent ecommerce datalayer push, but also needs one value as input. That is the GA4 ecommerce event name that belongs to that datalayer push, so that the correct enhanced ecommerce object can be formed.

In addition, there is the option to add custom item parameters, to translate them into custom dimensions or metrics. Because even though the new parameters are not stored anywhere by Google Analytics (and BigQuery if you have the export enabled), they may be relevant for your enhanced ecommerce implementation.

So you can add them to the data layer and then refer to the correct custom definition with the variable. Also, once GA4 adds the custom item parameters, you're ready to go.

For example, the demo mentioned above shows how the parameter 'item_type' is passed to UA as 'pr1cd1' (product 1 custom dimension 1 ). You can see this well if you use Tagbird 

tagbird-ga4-ecommerce
ecommerce

This is what you need to know about this variable. Hopefully it will help you make the migration to GA4 smoother.

Need help implementing GA4?

Are you looking for more help than this variable offers you? Then we would like to know exactly what you are looking for. Contact us, we are happy to help you! 

This is an article by Anton Bies, Technical Web Analyst at Digital Power

Anton is a big proponent of data-driven marketing. Not deciding what to do purely based on experience, intuition or 'this is what everyone does', but using numbers as much as possible. Anton's professional motto is 'measure what you want to know'.

Anton Bies

Technical Web Analystanton.bies@digital-power.com

Receive data insights, use cases and behind-the-scenes peeks once a month?


Sign up for our email list and stay 'up to data':