Google Analytics 4 (GA4) has been in beta development for quite a while since its release last year. We all saw how powerful and robust GA4 is to its predecessor Universal Analytics. It is driven by a new clean interface which is machine learning driven giving a ton of insight into the data you will be collecting. The new reports as well as custom reports are far superior to the older version. Google has finally decided to remove Universal Analytics completely and shift to GA4. As users we are bound to switch to the new version before the support for UA ends i.e July 1 2023. It’s only two months before universal analytics goes out of the picture. Today we have brought you this expert guide to setup Magento 1 GA4 (Google Analytics 4) with GTM. It contains detailed step by step setup to walk you through the entire process. We also have a M2 solution in the form of Magento 2 GA4 Google Tag Manager(GTM).

Benefits of Google Analytics 4

Google Analytics 4(GA4) is superior to its predecessor Universal Analytics in almost every aspect whether it be the interface, reports, real time data, debugging and more. There are several benefits of this revolutionary analytics platform:-

  1. The data method is no more session based rather its event driven.
  2. Customer journey is recorded in depth using both browser and app based tracking.
  3. Integrated privacy controls
  4. Media platform integration
  5. Highly improved debugging
  6. Prediction based reports for better guidence

Setup Magento 1 GA4 with GTM

Let us begin the setup for Magento 1 GA4 with GTM. The setup has following steps that needs to be followed correctly in order for the tracking to work:-

  • Knowing the events in GA4
  • Creating data layers on the store
  • Setup tags in Google Tag Manager
  • Test tags

GA4 Events

Google Analytics 4 is event driven tracking i.e specific actions taken by the customer on the store is sent as events to the analytics. There are several events in GA4 that each pertain to the relevant action. Below is the list of all events and their description:-

  • View_item_list:- Select an item from a list
  • select_item:- Select an item from a list
  • Add_to_cart:- add a product to shopping cart
  • Remove_from_cart:- remove a product from shopping cart
  • Add_to_wishlist:- add a product to wishlist
  • View_cart:- when cart page is viewed
  • View_promotion:- when a promotion is viewed
  • Select_promotion:- when a promotion is clicked
  • Begin_checkout:- when user initiates the checkout process
  • Add_shipping_info:- when user enters the shipping information
  • Add_payment_info:- when user enters the payment information
  • Purchase:- when a purchase is made
  • Refund:- when the refund is processed
  • View_item:- View item details

Create Data Layers on your Store

The must have requirement for this setup is to have data layer code implemented on your store. This data layer code captures the information related to particular actions taken by the user while browsing your store. For eg:- when a user views a product the data layer code captures the information related to the product such as name, sku etc. This information is then used by GTM to fire events and send these events to Google Analytics 4. Each event has a spearate data layer and we will start by shoiwng you data layer code for one of these events:-

Event Name:- view_item

Data Layer Code:-

dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object.
dataLayer.push({ event: "view_item", ecommerce: { currency: "USD", value: 7.77, items: [ { item_id: "SKU_12345", item_name: "Stan and Friends Tee", affiliation: "Google Merchandise Store", coupon: "SUMMER_FUN", discount: 2.22, index: 0, item_brand: "Google", item_category: "Apparel", item_category2: "Adult", item_category3: "Shirts", item_category4: "Crew", item_category5: "Short sleeve", item_list_id: "related_products", item_list_name: "Related Products", item_variant: "green", location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo", price: 9.99, quantity: 1 } ] }
});

Similarly you need to implement data layer code for all the events mentioned above. You can use the following USER GUIDE to implement these data layers.

Tag Setup for Magento 1 GA4 with GTM

Next we will be setting up our Google Tag Manager with correct tags, triggers, and variables to cater to the GA4 tracking. We will start by creating the Google Analytics 4 configuration tag.

There are several benefits of this revolutionary analytics platform:-

  1. The data method is no more session based rather its event driven.
  2. Customer journey is recorded in depth using both browser and app based tracking.
  3. Integrated privacy controls
  4.  Media platform integration
  5. Highly improved debugging
  6. Prediction based reports for better guidence

Create a Configuration Tag

The steps to create a configuration tag are listed below:-

Step 1:- Go to your GTM container and click on New Tag

Step 2:- Enter the name of the tag and click on ‘Tag Configuration’

Magento 1 Ga4: Create a new tag

Step 3:- From the tag type list select ‘GA4 Configuration’ tag.

Magento 1 Ga4:- Choose tag type

Step 4:- Extract the measurement ID of your GA4 property. The GA4 measurement Id can be found in GA4 property>Admin>Data Streams>Select site

Magento 1 Ga4:- measurement id

Step 5:- Enter the Measurement ID in the tag and click on Trigger

Magento 1 Ga4:- find measurement id

Step 6:- From the trigger list select ‘All Pages’ and save the tag. Now our configuration tag is ready. Publish the container to test the tag.

Magento 1 Ga4:-choose trigger

Create Google Analytics 4(GA4) Event Tags in GTM

Once our configuration tag is ready we will go on to create tags for each of the events. To create the tag please follow the GUIDE here which contains all the details related to the tag configuration. Let us create tag to using the configuration in the above guide to understand the process:-

Tag configuration:

  • Tag type: GA4 Event
  • Event Name: view_item
  • Data Layer Variables (Name – Data Layer Variable Name):
    • Ecommerce Items – ecommerce.items
    • Ecommerce Value – ecommerce.value
    • Ecommerce Currency – ecommerce.currency
  • Event Parameters (Parameter Name – Value):
    • items – {{Ecommerce Items}}
    • value – {{Ecommerce Value}}
    • currency – {{Ecommerce Currency}}
  • Trigger: event equals view_item

Trigger configuration:

  • Trigger Type: Custom Event
  • Event Name: view_item
  • This trigger fires on: All Custom Events

We used the information above to create the view_item tag which is shown in the image below:-

Magento 1 Ga4:- configuration tag

Similarly create all the tags that we have mentioned above in the blog.

Testing the Entire Setup

Once the GTM setup is ready it is now time to test our Magento 1 GA4(Google Analytics 4 with GTM tracking. We can test the setup using following tools:-

  • GTM Preview Mode:- You can use the GTM preview mode to test whether all the tags are firing correctly and event data is sent to GA4. To access the preview mode go to your GTM container and from the top right corner click ‘preview’. Enter the URL of your store and the preview mode window will connect. Perform actions on the site and based on that you will see events firing in preview mode:-
Magento 1 GA4:- Preview mode
  • Debugview:- The debugview is one of the best ways to test your setup. It shows all the events firing on the site in real time. To access debugview go to your Google Analytics 4 property then click on admin. Scroll down the middle row to find the debugview, click on it and the debugview interface will appear before you as shown in the below image. You should see all the events firing as you perform actions on your store.
Magento 1 GA4:- debugview
  • Real Time report:- As the name suggests the real time reports in GA4 gives you a ton of information from the data being collected on the stores. In this report you can also see events firing on your store. To access this report go to your GA4 property and from the left menu click on reports then again from the left menu click on Real time to access the report as shown below:-

Conclusion

In this guide we learnt how you can integrate Magento 1 GA4(Google Analytics 4) with GTM(Google Tag Manager) in detail. There are several steps in this guide which can be a bit tricky for some people. We have developed a fully tested module which will implement all the data layers for all the events automatically on your store. We also provide the GTM setup in a JSON file which contains all the tags, triggers, variables necessary for the complete setup. You won’t have to do a thing. If you are interested you can check our Magento Google Tag Manager with Enhanced Ecommerce Tracking and Google Analytics 4(GA4) module. We also offer both frontend and backend demos which can be access below:-

Frontend Demo

Backend Demo

Similar Posts