How to Add Google Analytics Code in Magento 2 [2024]
Hassle-free Magento 2 GA4 Integration
Set up GA4 in just few easy steps using our Magento 2 GA4 extension.
Pondering how to add Google Analytics code in Magento 2? Read this step-wise guide to connecting Google Analytics (UA) to Magento 2 store.
Google Analytics needs no introduction. It is a popular web traffic and user analytics platform used by millions of webmasters worldwide. It provides in-depth analysis of the user behavior on the site to make data-informed decisions. According to W3techs, the Google Analytics service has been detected on more than half of the websites on the internet.
Let’s say you built a store on Magento 2, started receiving traffic, and got some orders. Adding a web traffic analytics tool can help you understand where those customers came from, and how many of them purchased. This can help you understand what’s working for your store and what’s not, helping you create a successful business strategy.
Google Analytics in Magento 2 can help you analyze the traffic sources, customer behavior, clicks, most visited pages, number of repeated customers, and much more. This can help you plan product strategy and the marketing strategy accordingly.
In this blog post, find the complete steps to add Google Analytics tracking code to Magento 2.
Let’s dive in…
Steps to Add Google Analytics Code to Magento 2
Setting up Magento 2 Google Analytics is a straightforward task. All you need to do is create a Google Analytics account, get the tracking code, and add it to your Magento 2 store. Here are the steps to set up Magento Analytics:
- Step 1: Create a Google Analytics Account
- Step 2: Set up Website Property
- Step 3: Get Google Analytics Tracking ID
- Step 4: Add Google Analytics Code in Magento 2
Now, let’s see the complete method of adding Google Analytics to Magento 2.
Step 1: Create a Google Analytics Account
First, you need to create a Google Analytics account. (Skip this if you already have one!)
Go to Google Analytics and log in using your existing Google account or create a new one. Enter basic details and complete the account setup.
Step 2: Set up Website Property
Next, you’ll be prompted to choose the data source for the analytics.
Select Web as we are going to connect the Magento 2 Google Analytics.
Next, you need to enter some more basic details about your website.
You need to add details such as Website Name, Website URL, Category, and select the time zone to get started.
Enter the required details and click Create to create the web property.
Step 3: Get Google Analytics Tracking ID
Next, you need to add the Google Analytics Tracking ID to the website.
This way Google can verify that you’re the owner of that website.
To get the tracking ID for the Google Analytics Magento 2 integration, go to Google Analytics Dashboard > Property > Property Settings > Tracking code.
Copy the Google Analytics tracking ID, which you’ll require to add into Magento 2 backend.
Step 4: Add Google Analytics Code in Magento 2
Finally, you need to add the Google Analytics tracking ID to Magento 2.
To do that, log into your Magento 2 admin panel, and navigate to Stores > Configuration > Sales > Google API.
Expand the Google Analytics section, enable it and enter the Tracking ID that we copied in the previous step in the Account Number field.
After you add the Google Analytics code to Magento 2, click Save Config button.
Voila!! 🎉 You’ve successfully connected Google Analytics with Magento 2. Go to the GA dashboard and you’ll be able to track your Magento Google analytics data in real-time.
That’s it!
Your Magento 2 Google Analytics setup is ready to help you make data-driven decisions.
I hope the above comprehensive method will help you add Google Analytics code to Magento 2. It is important to note that Google Analytics 4 will soon replace the Universal Analytics. In case you’re a Magento 2 store owner, you can install our Magento 2 Google Analytics 4 extension to do that. It comes with built-in eCommerce events and lets you seamlessly track data in our Magento 2 store. Explore the free live demo of extension to know more.
Shivbhadrasinh Gohil
Shivbhadrasinh is the Co-founder & Chief Marketing Officer at Meetanshi. He leads the marketing team and is the person behind the marketing & branding success of the company. Being a seasoned digital marketer, he has been consulting online businesses for growth since 2010 and has helped 100+ clients with digital marketing success.
He loves sharing tips and insights about the latest digital marketing trends aimed at helping online business owners.
2 Comments
Hi,
How to get transactions to Google Analytics from Magento 2? 🙁
Hello Bogumil,
You need to code for Google analytics.
Then Go to Google Analytics Admin -> View -> Ecommerce setting
Enable eCommerce and enhanced eCommerce Reporting and click on “Save”.
Thank You.