Migrating GTM Based Enhanced Ecommerce Setup to Google Analytics 4 (GA4)

Google Analytics 4 (GA4)  has taken the web analytics world by storm. It provides a more granular and different data collection approach compared to Universal Analytics and GA360. The lowest and only quantum of information that’s stored in GA4 is an event record. The metrics of Universal Analytics like page views, session ID are all recorded as an event or an event parameter. Data from Web, App, or any other measurement protocol can flow into a single property making cross-device and cross-application tracking much more robust. 

The biggest advantage of GA4 is that it provides access to the big data warehouse free of cost to anyone with the help of Big Query. Unlike Universal Analytics where Big Query was available at a cost, GA4 gives retailers the ability to create their own data lake at no cost. The benefits include the ability to create user segmentation, build personalization and recommendation engines, and more. So we recommend migration to GA4 if you are using Universal Analytics. Even for Shopify, Magento and Woo Commerce store owners which have implemented Enhanced Ecommerce through GTM, this blog can help in setting up the tags.

The setup of GA4 requires few configuration changes within the Google Analytics interface and the configuration of GA4 tags for the e-commerce stages. The first step is to enable GA4 property using the GA4 Setup Assistant. This can be found under the Admin section and the property settings. Once you complete the process through the setup assistant, a new GA4 property should show up under the account in a  while. 

Next go to the new GA4 property and in setting under data streams of the store, note or copy the Measurement ID of your GA4 property as seen below.

The next Step Involves going to the tag manager through which the existing universal analytics code and other tags for the store have been implemented. In the Tag Manager, the first tag to be setup is the GA4 Configuration Tag which needs to be set up on all page view triggers like the standard Universal Analytics tag. The measurement ID copied from the GA4 Data stream can be copied here. This tag will set up basic GA4 tracking without any enhanced ecommerce functionality.

An enhanced ecommerce setup in GA using GTM should have various tags like Product Impression, Product Detail View, Add to Cart, Checkout, Remove from Cart, Payment and Purchase. As these tags and data layer values have already been implemented, setting up GA4 tags will be simpler. In case you haven’t done enhanced ecommerce setup before and data layer implementation does not exist, read through this developer guide. In this blog, we will assume the data layer implementation is in place. So we need to create tags similar to enhanced ecommerce tags of Universal Analytics and create GA4 Event Tags for various stages.

Events in GA4 don’t have the standard fields of Event Category, Action, Label, and Value and do not automatically fetch ecommerce values through the data layer. However, all attributes including item details like products, price and other attributes can be passed using the data layer variables to GA4. Data layer variables of ‘ ‘ecommerce impressions’ and ecommerce.add.products’ or ‘ecommmerce.detail.products’ should be available in the data layer depending on the stage and can be passed to GA4 tags by creating a data layer variable.

Below is a mapping of Event Names, Data Layer Variables, and Event Parameters to be created and passed for each stage

StageEvent NameData Layer Variable to be created for ‘items’ parameter
Product Impressionview_item_listecommerce.impressions
Product Clicksselect_itemecommerce.click.products
Product Detail Page (PDP)view_itemecommerce.detail.products
Add to Cartadd_to_cartecommerce.add.products
Remove from Cartremove_from_cartecommerce.remove.products

So for example your tag for PDP should look similar to the one given below. Here the data layer variable {{Ecommerce Items PDP}} has been created to refer  to ‘ecommerce.detail.poducts’. Similar data layer variables will need to be created for all stages.

For the purchase stage, additional event parameters and data layer variables will need to be created including event parameters/data layer variables of: 

  • items – {{Ecommerce Items}}
  • transaction_id – {{Ecommerce Transaction ID}}
  • affiliation – {{Ecommerce Affiliation}}
  • value – {{Ecommerce Value}}
  • tax – {{Ecommerce Tax}}
  • shipping – {{Ecommerce Shipping}}
  • currency – {{Ecommerce Currency}}
  • coupon- {{Ecommerce Coupon}}

Once these tags are created and passed for each stage, the required event details will start passing to GA4 and can be tested through GTM preview mode before taking live.  Within a few hours, you should start seeing detailed events being recorded in GA4. In case Big Query is implemented, the details of these events can be tracked at a detailed level, thus enabling data warehouse functionality for your ecommerce store. To get further help in setting up enhanced ecommerce in GA4 for your store or setting up a GA4 data warehouse drop in a note to contact@deepflux.io and we will get in touch with you and set up the complete warehouse for your store.