Google Analytics and Magento 2

Google Analytics is an important tool for merchants in the eCommerce and Magento communities because it allows merchants to make informed decisions about their website based on their users’ interactions. With the advent of Magento 2, it’s important to understand how the new version utilizes and integrates with Google Analytics. If you’re familiar with Magento 1, you’ll remember that Google Analytics was fairly easy to setup so you could quickly view reporting data. What about Magento 2? Don’t worry, integration with Google Analytics offers additional features with the same setup ease.

What’s the Same?

  • Universal Analytics – Magento 2 still features the same quick-and-easy Google Analytics setup. It’s just a matter of enabling the Google Analytics setting and adding your account number. Thankfully, the deprecated option of ‘Google Analytics’ (as opposed to ‘Universal Analytics’) is no longer around to add confusion during setup.

alt text

  • Adwords – this hasn’t changed in Magento 2; it’s still just as easy as adding your Conversion ID and Label.
  • Ecommerce Tracking – One very powerful feature that seems to fly under the radar is eCommerce tracking. This feature is a must-have for any eCommerce site and lets you track transaction and product data on your site. If you already use Google Analytics with Magento, you get this feature with almost no setup. The only thing required to start using eCommerce tracking is to enable this feature in your Google Analytics account. Magento does the rest.

alt text

  • Google Tag Manager – Magento 2 Enterprise Edition includes the option to use Google Analytics via the flexible option of Google Tag Manager.

What’s New?

Magento 2 supports a Google Analytics feature called Content Experiments. This feature allows you to setup A/B tests on your Magento site to track how different versions of pages perform. Although its simplicity makes it a good solution for small-scale A/B tests, I don’t think it’s a good solution for complicated A/B testing.

To set up content experiments, (and after toggling the feature on in Magento admin configuration settings), there are only two steps:

1. A new experiment needs to be setup in your Google Analytics account. This is pretty straightforward. (Make sure to select the option to manually insert code and save this for the next step). You can follow the instructions from Google here.

alt text

2. Connect the new experiment with Magento. Create at least two new CMS pages, (this can be done with any number of different variants), your ‘original’ version and a ‘variant’. Place the javascript snippet from the experiment setup in the previous step under the new tab, ‘Page Experiments’. Just like other Google Analytics features, Magento handles rendering the snippet in the correct place on the frontend.

alt text

That’s it! The way this simple example experiment has been set up, half of the visitors will be sent to the original page, and half to the variant. You can track how your experiments are trending in the reporting section of your Google Analytics account under Behavior > Experiments.

To learn more about how Classy Llama approaches A/B testing check out this post.

What else?

A lot of our clients are interested in eCommerce tracking. And while the eCommerce tracking provided by Google Analytics provides a lot of good data, it can sometimes be hard to visualize or grasp what you’re looking at. This is where goals and funnels come in.

  • Setup your goal(s). This can be done many different ways depending on what you are wanting to track and how your user interacts with the site. Google provides documentation on setting this up different ways. A basic example of a goal is a user completing an order (reaching the success page).

alt text

  • One thing to keep in mind: By default, Google tracks views on secure urls separately from unsecured urls. So if you use a destination goal which includes both secure and unsecured pages, you will need to setup cross domain tracking.
  • The funnel visualization view (Under Conversions > Goals) can provide great insight into how users are moving through your website and reveal pages that have unusual rates of drop-off.

alt text

Another common thing to track is cross-sells/upsells. A merchant may want to know how often an advertised cross-sell product is clicked. To accomplish this, an event (or trigger if using Google Tag Manager) needs to be setup to let Google know when a cross-sell product is clicked. You can do this in Google Tag Manager, or by adding some javascript: javascript ga('send', 'event', 'cross-sell', 'click', '{product-id}');Then in the Google Analytics dashboard, setup an event goal:

alt text

Both of these goal examples can easily be modified to include different steps in the flow or more complicated events. You can view reporting details about any of the goals you’ve set up under Conversions > Goals > Overview.

These are fairly simple examples, that just skim the top of what this feature can provide.


By expanding the features in the integration of Google Analytics, Magento 2 empowers merchants to make informed decisions about their site. And the setup ease of content experiments, eCommerce tracking, and the other Google Analytics features allow merchants to focus their efforts on improving the performance of their website.

Recommended Posts

Leave a Comment