Evrig

In today’s data-driven world, Google Analytics 4 has become an essential tool for e-commerce businesses. Its advanced features and capabilities provide invaluable insights into customer behavior, helping businesses make informed decisions and drive growth.

Why Do You Need to Setup Google Analytics 4 on Magento 2?

For online store owners, data is crucial for making informed business decisions. With the impending replacement of Universal Analytics by Google Analytics 4 starting from July 1, 2023, it becomes imperative for Magento 2 store owners to make an immediate switch to ensure uninterrupted data collection and analysis.

  • In-built e-commerce tracking
  • Batter sales data
  • New data tracking model
  • Create custom-events
  • Unified Web and App analytics
  • Custom report generation

How To Setup Google Analytics 4 In Magento 2

For simple blogging website

Setting up Google Analytics 4 (GA4) in your Magento 2 online store doesn’t always require purchasing additional extensions if you haven’t any items or ecommerce store. With a few simple steps, you can easily copy the code from your GA4 property and add it to the head file of your Magento 2 website. This allows you to start collecting valuable data without any extra cost. Here’s an example of how you can do it:

Accessing your Google Analytics 4 Property:

Begin by logging into your Google Analytics account and accessing your GA4 property. If you haven’t created a GA4 property yet, follow the instructions provided by Google to set it up.

Copying the GA4 Tracking Code:

Once you’re in your GA4 property, navigate to the Admin section and click on “Data Streams.” Select the appropriate data stream for your website and copy the GA4 tracking code snippet.

Accessing the Magento 2 Admin Panel:

Log in to your Magento 2 admin panel using your credentials. From the dashboard, navigate to Stores > Configuration.

Adding the GA4 Tracking Code:

In the Configuration menu, expand the “General” section and click on “Design.” Open the “HTML Head” tab, where you will find the “Scripts and Style Sheets” field. Paste the GA4 tracking code snippet into the “Scripts and Style Sheets” text area.

Saving and Verifying the Changes:

Save the configuration changes and clear the cache in your Magento 2 store. This ensures that the GA4 tracking code is added to all the pages of your website.

Verifying GA4 Integration:

To verify if GA4 is successfully integrated into your Magento 2 store, visit your website and check the source code. Look for the GA4 tracking code in the head section. You can also use the Real-Time reports in your Google Analytics account to see if your website is actively sending data.

For eCommerce Store

If you have an eCommerce site then you need to track custom events. When it comes to tracking important events in your e-commerce store, such as add to cart, purchase, remove from cart, view items, checkout, relying solely on basic tracking methods might not provide the depth of insights you need. In such cases, purchasing specific extensions for your e-commerce platform can be highly beneficial. These extensions are designed to enhance e-commerce tracking capabilities, providing you with valuable data to optimize your marketing strategies and improve conversion rates.

While there are numerous paid extensions available in the market for enhancing e-commerce event tracking in your online store, not everyone may be willing to invest in them right away. However, there is a free alternative that you can consider exploring. Before purchasing any other extensions, I recommend trying out a free extension that I personally tested when it was live on GitHub. It’s worth giving it a shot to see if it meets your requirements and saves you the expense.

This free extension will track this events:

  • View_item
  • View_item_list
  • select_item
  • add_to_cart
  • remove_from_cart
  • view_cart
  • begin_checkout
  • add_payment_info
  • add_shipping_info
  • purchase

Free Magento 2 Google Analytics 4 Extension

You just need to follow simple steps to install the free google analytics 4 extension. You can also take help from your developer to do this task easily.

After installing the extension, You need to create a Google Analytics 4 Property and Google tag manager account. After that You need to download this JSON file .

And then update ACCOUNT_ID, CONTAINER_ID, CONTAINER_NAME, and GTM_PUBLIC_ID.

Make sure to reset the Measurement ID to be your own.

After this, you need to go to the Admin section from Google tag manager. Click on Install Container. And upload a JSON file there.

You can follow this guide.

That’s how easy it is to setup Google Analytics 4 in Magento 2 using this free extension.

If you have any doubts or face any issue during the setup, feel free to comment or contact us, I would be happy to help you.