How to add Google Analytics to Magento 2

Google Analytics is a potent tool for e-commerce businesses to track website traffic and customer behavior. If you're running an online store on Magento 2, integrating Google Analytics into your business strategy is an absolute must to gain valuable insights about your customers and make informed, data-driven decisions that can improve your online presence. Using Google Analytics, you can understand your customer's behavior accurately, such as which pages they're visiting, how long they stay on the page, and where they're coming from. In addition, you can also track conversions, sales, and other key performance indicators (KPIs) to understand your customer base better and create effective strategies to drive more traffic and conversions. Ultimately, Google Analytics gives you the data to make the best decisions for your e-commerce business.

This blog will go through the steps to add Google Analytics to Magento 2.

Step 1: Create a Google Analytics account

If you still need a Google Analytics account, go to and sign up. Once you've signed up, you'll need to create a property for your website.

Step 2: Get the tracking code

Next, you'll need to get the tracking code for your website. Go to your Google Analytics account's Admin section and click "Tracking Info" and then "Tracking Code."

Copy the tracking code provided. You'll need this code in the next step.

Step 3: Add the tracking code to Magento 2

In your Magento 2 admin panel, go to "Stores" and "Settings." Click on "Configuration," then go to "Sales" and then "Google API."

Under "Google Analytics," paste the tracking code you copied from Google Analytics in the "GA Code" field. Then, select "Yes" for "Enable" and click "Save Config."

Step 4: Verify the installation

To verify that the installation was successful, return to your Google Analytics account and click "Real-Time" and then "Overview." If the tracking code works correctly, you should see the number of active users on your website.

Step 5: Start tracking

That's it! You've successfully integrated Google Analytics into your Magento 2 website. Now, you can start tracking website traffic and customer behavior. You can see the data in your Google Analytics account and use it to make informed decisions about your online store.

In conclusion, integrating Google Analytics into your Magento 2 website is a quick and easy. You'll gain valuable insights into your customers and website traffic, which can help you make data-driven decisions to improve your online presence.