the blog

Steps to Set Up Google Analytics 4 for Magento 2

Google stirred the eCommerce world in October 2020 when it announced that the Universal Analytics solution would cease to be functional from July 1, 2023. Hence, the stores that track customers and traffic using Universal Analytics will have to mandatorily migrate to Google Analytics 4.

In this blog, we have discussed how to set up Google Analytics 4 for Magento 2.

Before diving into the topic, let’s discuss some

Fun Facts on Google Analytics:

  • Currently, there are about 28.1 million websites that use Google Analytics, which is expected to rise in the upcoming years.
  • Among all the popular analytics software development kits (SDKs), Google Analytics ranks third.
  • Retail websites have around 6% of Google Analytics users, and the marketing industry is the leading user of Google Analytics with about 47, 128 customers.
  • Approximately 5.8 million websites are currently using Google Analytics 4.

What is Google Analytics 4?

Known to be among the most popularly used tracking tools on the market, Google Analytics allows users to collect data that will help make relevant business-related decisions. Primarily, Google Analytics tracks essential metrics related to website traffic and visitors like Page Views, Bounce Rates, Traffic Sources, Session Times, etc. Also, it facilitates real-time tracking of the number of visitors on the website at a given time, their geographical location, and what they are browsing.

The recent and most advanced version of Google’s free analytics tool is Google Analytics 4. The transition from the sessions to events is the major point of differentiation between Universal Analytics and Google Analytics 4 which facilitates collecting standardised data across all platforms. This helps get a single report along the entire user journey. At the same time, Google Analytics offers machine learning and Natural Language Processes (NLP). This makes it possible to estimate the possibility of conversion and use that information in Google Ads Campaigns. At the same time, glitches in reports including no conversion tracking or incorrect conversion coefficient calculations can be tracked using machine learning.

How to Set Up Google Analytics 4 for Magento 2?

Setting up Google Analytics 4 for Magento 2 can be quite challenging as not only are there quite a few steps involved but requires coding knowledge. Installing Magento 2 Google Analytics 4 module is the best solution, allowing quick integration of Google Analytics 4 with your Magento 2 store without proper technical knowledge.

It supports several advanced features:

  • Real-time tracking of 5 default and popular events with eCommerce.
  • Doesn’t require manual event creation.
  • Admin can identify a product through product ID/SKU.
  • Brand-wise performance tracking is now easy.
  • The product variant feature can be enabled from the backend.

Are you planning on doing the integration on your own?

If yes, then you need to have a Google Analytics account first. To create an account, go to Analytics under Marketing Platform, and click on Get Started Today to create an account. Once you have your account, you would have to tag your Magento store with Google Analytics 4.

Let’s get into the process step-by-step.

1. Create a Google Analytics Property: To create a new Google Analytics property, log in to your Google Analytics dashboard. Go to Account Settings under the settings option and click on Create Property under the Property Section. Once the window opens, enter Property Name, Reporting Time Zone, and Currency, and click Next. You can add business-related data with Google to personalise your experience. However, it isn’t a mandatory step. Lastly, click on the Create button.

Google Analytics Property

Set Up Data Stream and Get the Measurement ID: Once you’ve created the property, add a Global Site Tag followed by setting up a Data Stream (to get an idea of the data that is collected). From the Choose a Platform, choose Web since you are setting up Google Analytics 4 for your e-store which will open a window where you would need to set up your data stream and get your Measurement ID. Here, you would need to enter your Website URL and Stream Name. You’ll come across some default tracking and insights under the Enhanced Measurement Section. Click on Settings to get more information about the captured events and disable the insights you do not require. Then, click on Create and the Web Stream Details window will open where your Measurement ID and tagging instructions to add the Tracking ID to your Magento store will be displayed. Go to the Tagging Instructions tab and expand the Install Manually section and copy the Global Site Tag script there.

Data Stream

Set Up the Global Site Tag in Magento 2: Once you have the Google Analytics 4 Global Site Tag, go to your Magento Admin section and add it to your site. To do so, log in to your Magento Admin and go to Content followed by Design and Configuration. Pick the store view as per your preference and add Google Analytics Global Site Tag and click on Edit. Enlarge the HTML Head section and paste the Google Analytics code in the Scripts and Stylesheets box and select Save Configuration. Go to System under the Magento Admin section then go to Cache Management under Tools, followed by clicking the Flush Magento Cache button. Reload your Magento 2 store frontend and the website would be tagged with a Google Analytics tracking code.

 Google Site Tag Setup

Verify if the Store is Tagged Correctly: Among the different ways to verify if your store is tagged, we have listed the two simplest ways:

  • By Inspecting the Source Code: Go to the front end of your website and click on View Page Source after right-clicking. You’ll find the Tracking ID inside the tag that you inserted in the last step.

Note: In case you don’t see the Tracking ID, you haven’t either cleared your store’s cache or are using a CDN.

  • By using the Tag Assistant Extension: Using the Tag Assistant Browser extension is another way to confirm if the Google Analytics 4 Tag is present. However, this Google extension isn’t 100% safe. You would have to install the extension from the extension store in case you don’t already have it. Once it is installed, click the extension and click on Enable. Next, reload the page and click on the extension again. Doing so, you would get to view the Global site tag in the Analysis section. Using the Tag Assistant extension, you can check information about your Google Tag including Container ID, Account ID, etc.

Wrapping Up,

Now that you know why you should migrate to Google Analytics 4 immediately; you need to look for experienced and certified developers to help you migrate. Contact us at 18th DigiTech, an award-winning eCommerce Agency and an Adobe Gold Solution Partner. Our team of developers, designers, and digital marketers is available 24/7 to help you achieve every business goal you may have.