Get a fast, conversion-focused WooCommerce theme in 2024. Switch to Shoptimizer.

Home eCommerce Guides Grow your business Google Analytics for WooCommerce

How to add Google Analytics to your WordPress and WooCommerce website

Google Analytics for WooCommerce

In this guide I’m going to show you exactly how to add Google Analytics to your WordPress and WooCommerce powered online store. Google Analytics is the undisputed king of the website and eCommerce analytics world. There’s simply no other platform that comes even close to providing what Google Analytics can do for free (as long as you’re comfortable giving all your website data to Google that is!).

There are a whole range of statistics, metrics and key performance indicators (KPI’s) that the world’s largest eCommerce websites know inside and out and watch and analyze in real time to understand if they’re cashing bonus checks for their quarter or whether they need to start tightening their belts. It doesn’t matter if you’re running a billion dollar eCommerce empire or are just getting started selling your handmade monkey mugs, eCommerce Analytics is the central nervous system of your online business and it’s vital you get your Analytics systems setup correctly before you can truly measure the performance of your online business.

While there are tons of existing guides on how to setup Google Analytics for WordPress and WooCommerce, many of them are full of poor advice or only get you half way there. If you’re trying to grow an online store, half measures simply aren’t good enough! So we’ve put together a comprehensive guide to make sure you’ve got everything you need to know exactly what is happening with your eCommerce website from basic analytics through to sophisticated Checkout behaviour analysis.

Let’s dive in! This is a 3-part guide:


Part 1 – How to setup and optimize Google Analytics for WooCommerce

Step 1 – Create a new Google account for your eCommerce business

If you’ve never used Google Analytics before, the very first thing you’ll need to do is setup an account.

Pro Tip! DON’T setup Google Analytics under your personal Google account. Always, always create a separate Google account for your eCommerce business.

That way in a few years time when Warren Buffet gives you a call with that $100 million acquisition offer, you’re eCommerce Analytiics aren’t stuck inside your personal account 🙂

Step 2 – Sign up for Google Analytics

The  setup process is pretty straightforward. Head to the Google Analytics login to sign up for Google Analytics.

Complete the new account Sign up step. Most of these details on this screen are self-explanatory. Just watch out to make sure you select https for your url AND make sure to select your time zone so that you can clearly see when your website activity is happening 🙂

After you’ve signed your life away to all Google’s Terms of Service (!) you’ll end up at a screen that looks something like this. The most important piece of data on this screen is your Tracking ID. This is the key you’ll be using when we connect WordPress and WooCommerce to Google Analytics (GA).

Step 3 – Activate Enhanced eCommerce

Next, go to Admin -> Ecommerce Settings

Under Ecommerce set-up ensure that Enable Ecommerce and Enable Enhanced Ecommerce Reporting are both switched on.

We’re not going to our label our Checkout just yet. Go ahead and click Save.

So that’s our Google Analytics account setup, let’s get cracking with our WordPress and WooCommerce configuration.


Part 2 – How to add Google Analytics to WordPress and WooCommerce the right way

There are a ton of different ways to add Google Analytics to WordPress and WooCommerce. Let’s quickly list how you shouldn’t do it!

  • Do NOT add your Tracking ID to your Theme control panel. Never ever do this. Just don’t. It’s a recipe for disaster. I know many theme authors promote this as a feature of their theme. It’s not. It’s an accident waiting to happen. If you ever decide to switch to another WooCommerce theme you’ll probably have forgotten by then that you configured Google Analytics via the theme – and poof! There goes your Analytics. By the time you figure it out you’ll probably have lost days of precious data. Theme authors- shame on you – you should know better – ditch those Google Analytics ‘features’.
  • Do NOT add your Tracking ID to your theme source code. This is also an accident waiting to happen. If you’re using a WooCommerce theme and start editing the source files of the theme to add tracking codes, you’ll lose your Analytics the second you update the theme. Many will get around this by adding it to a child theme instead. Ok cool – if you’ve already got a child theme that’s not the worst case, but you’re still on the hook for managing this code and you’ll need to ensure you never ever delete it!

So now you know how NOT to do it, what’s the correct way to add your Google Analytics Tracking code to WordPress and WooCommerce? Well, there’s actually a two ‘right’ ways to do it 🙂

  • Method 1 – Using a trusted Google Analytics WordPress plugin with excellent support for WooCommerce
  • Method 2 – Using Google Tag Manager

Method 1 – Using a trusted Google Analytics WordPress plugin with excellent support for WooCommerce

There are tons of WordPress plugins that allow you easily add Google Analytics support to your WordPress website. There are also quite a few of these plugins that provide support for WooCommerce. However, what you’ll find is that many of the free versions of these plugins and extensions suffer from quite a few limitations when it comes to deep integration with advanced Google Analytics features like Enhanced eCommerce, Dynamic Remarketing and Checkout Behaviour analysis. In some cases you might be content to live with those limitations (depending on the types of products what you’re selling in your store). Here are my recommended, tried and test WordPress Google Analytics plugins with WooCommerce support along with the pros and cons of each.

WooCommerce Google Analytics by WooCommerceThe best all round free option

My first recommendation is the most basic WooCommerce plugin direct from the WooCommerce team itself. While this plugin has never had an amazing rating (currently 3/5 with over 90,000 active installations at the time of writing) I’ve always found it to be the most solid of the free plugin options available. Unlike many of the other free WooCommerce plugins, it provides full support for Enhanced eCommerce tracking. That alone is really important for me. Other highly rated WordPress Google Analytics plugins certainly do provide a lot more bells and whistles with how they integrate with Google Analytics, but tend to limit their enhanced eCommerce support (either by not providing it all or only for simple product types).

If you’ve been using WordPress and WooCommerce for any amount of time you quickly learn that sometimes good plugins go bad. Either the plugin author ceases to maintain the plugin, or stops providing support, or starts severely restricting the plugin in favour of upselling a premium version. As this plugin it coming from the mothership itself that provides a certain level of comfort that it will be maintained as WooCommerce evolves over the coming years. And while they may not always be the fastest to respond, you can be safe in the knowledge that the plugin has the major benefit of being supported by the main WooCommerce customer support team. So while there might be more highly rated plugins right now that you might be attracted to, do me a favour and consider the longevity of the team behind the plugin and the level of support they provide before you run off with them 🙂

WooCommerce Google Analytics Pro by WooCommerceThe best paid option

The free version of the WooCommerce supported plugin is certainly sufficient to get you up and running quickly for free if you’re on a tight budget. But if you can justify a small investment in the pro version I would highly recommend it.

Why?

  • Support for Shopping and Checkout Behavior Analysis – These 2 alone are worth the pro license alone. If you’re serious about understanding what your customers are doing then you need this.
  • Advanced eCommerce Event tracking – the pro version expands the number of events that are tracked and lets you switch on/off events and even rename them if you wish.
  • User ID tracking – if you need more data about your specific users and customers the pro version can do it.

Again, you get the benefit of support from the mothership and not some fly-by-night outfit who might disappear overnight. While the plugin is sold by WooCommerce, it’s actually developed and maintained by one of the best WooCommerce development teams on the planet called Skyverge.

Right now, the pro version can be purchased for $79 for a single site license.

If you’re in a hurry, pick one of these 2 plugins above and get cracking! If you’d like to spend more time experimenting with alternatives, here’s the best of the rest I’ve used over the years and can vouch for.

MonsterInsightsBest free Google Analytics plugin for WordPress (with excellent pro addon for WooCommerce)

MonsterInsights has over 2 MILLION installs and over 700 5 star reviews at the time of writing. It’s my go to plugin for WordPress websites where I’m not using WooCommerce. The only reason I wouldn’t recommend MonsterInights for a WooCommerce website is you’ll get no support for things like Enhanced eCommerce with the free version. But, if you’ve got a budget, the eCommerce addon is definitely an excellent alternative to our top recommendation.  MonsterInights is also backed by one of the most successful WordPress businesses on the planet, Awesome Motive. If hands on support is more important to you than scrimping over the small cost of a plugin license, then I would go so far as to say you should probably consider MonsterInsights and their eCommerce addon as your top choice as the MonsterInsights support response times tend to be lightning quick and awesome 🙂

Enhanced eCommerce Google Analytics Plugin for WooCommerce

This is another solid plugin you can use in combination with MonsterInsights instead of their eCommerce addon. While it’s a very popular plugin, I would only feel comfortable recommending their free version if you’re running a very simple WooCommerce store. Why?

  • The free version only supports simple products in WooCommerce.
  • No support for Subscription products.

Not a fan of using plugins? Then you might be interested in a very compelling and powerful alternative method. Read on for more 🙂

Method 2 – Using Google Tag Manager

Google Tag Manager (GTM) is a VERY powerful and sophisticated way of augmenting a website with all sorts of tags that are becoming more and more commonplace when running any modern website.

But be warned, it’s definitely going to take a bit longer to setup Google Tag Manager for WooCommerce than the plugin based methods we’ve already described. So why then pray tell would you even want to use GTM instead? I think can tell you a few reasons:

  • You might already need or use Google Tag Manager to deploy tags for other integrations you need to setup. Tag managers have almost reached the point where they’re becoming a must have feature for your website infrastructure. If that’s the case for you, then it can makes sense to re-use your existing setup rather than having to manage and maintain yet another plugin. (And remember mo’ plugins, mo’ problems with security, performance, maintenance and cost)
  • More control over your Google Analytics integration – most plugins are pretty rigid when it comes to how they integrate with Google Analytics. With GTM, you have pretty much got complete control over what tags you serve and what triggers and variables you use to serve them.

Personally, I’m leaning towards using GTM more and more for all sorts of tag and pixel integrations purely just to cut down on the amount of time I spend managing plugins. So if you like the sound of that and have a bit more spare time to get everything up and running then it’s worth a shot 🙂

Step 1 – Sign up for Google Tag Manager

Head over to Google Tag Manager and Sign up (under your eCommerce Google account remember!). Sign up is pretty straightforward, remember to choose “Web” during sign up.

Once you complete sign up you’ll see a screen which includes you’re all important GTM ID. (NOTE: It’s the ID in the format GTM-XXXXXXX ).

Hit OK and move on to Step 2.

Step 2 – Install and configure DuracellTomi’s Google Tag Manager (GTM4WP) for WordPress

Wait, didn’t you just tell me I’d have less plugins to worry about?? Yip I did 🙂 But hear me out. This fantastic plugin is the key to unlocking all the value of GTM for your WooCommerce website. Think of it this way. If you have 10 tags/pixels that need to be fired on your WooCommerce website, would you rather have 10 plugins (1 for each tag) or a single plugin that allows you to add those 10 tags to GTM? That’s what GTM4WP does for you. But I’m oversimplifying its value a little. GTM4WP provides all sorts of wonderful support for WooCommerce events like triggering events when your customers add products to their cart which you can attach GTM events to. This allows you to build very sophisticated GTM triggers and full support for things like Enhanced eCommerce – 100% free!

So go ahead and install and activate GTM4WP.

Once activated, you should see a message like this in your admin screen.

Go ahead and click that link and enter your GTM ID on the main GTM4WP setting screen as follows:

You’ll notice I also selected Codeless injection too. Although GTM4WP flag this as being an experimental feature I’ve found it to work quite well and I’d rather have the code in the recommended place and not have to edit any files. If you experience errors with your site after switching to Codeless injection you can always switch back to the Footer option.

Click Save Changes and then click on Integration -> WooCommerce

There are 5 checkboxes that I usually tick on this screen – I leave everything else as is (for now):

  • Track enhanced e-commerce – duh! Yip we definitely want this 🙂
  • Cart as 1st checkout step – for WooCommerce out of the box, this is useful
  • Customer data in data layer – very useful if we want to trigger some pixels events based on customer value.
  • Exclude tax from revenue – important for lots of reasons so you don’t over estimate revenue analytics.
  • Adwords Remarketing – while we’re not using this today it’s useful to have it there for when we need it.

There are tons of other features you may wish to experiment with enabling, but for now that’s all we need to do to configure GTM4WP.

NOTE: If you have any other Google Analytics plugins/tracking methods setup, now would be a good time to deactivate them to ensure you’re not double tracking your website activity.

Step 3 – Configure Google Tag Manager

Let’s head back over to Google Tag Manager and setup our first tag!

In your default Workspace, click on Tags -> New

Then, give the tag a sensible name. One thing you’ll find out pretty quickly in GTM is that your tag naming convention is really important. Once you’ve got a dozen tags in GTM if you’ve not adopted an intuitive naming convention you’ll quickly discover it becomes tricky to find out which tags are doing what, especially when you’ve got multiple tags for a given service. For that reason I tend to use something like SERVICE – TAG in Tags, SERVICE – EVENT in Events and so on. But you do what works best for you. So given this is our default Universal Analytics tag, I used Google Analytics – UA for this tag name.

Then click on Choose a tag type to begin setup … and you’ll see something like this. Select Google Analytics – Universal Analytics as your tag type.

You’ll then see a Track Type dropdown, select Page View.

Next, you’ll see under Google Analytics Settings that you need to select a Settings variable. If this is your first time using Google Analytics in GTM you’ll need to set one up by selecting New Variable.

Give your variable a name and enter your Google Analytics Tracking ID. 

You can leave everything else as is. Click Save.

Sidenote: Can’t remember your Tracking ID? You’ll find it in Analytics -> Admin -> Tracking Info -> Tracking Code

You’ll end up back on the tag configuration screen. Normally we’d be pretty much done with a UA tag setup. But since this is an eCommerce website, we’ve one final important step to complete. Click Enable overriding settings in this tag. Then scroll down expand Ecommerce and select True from the Enable Enhanced Ecommerce Features. Finally, select Use Data Layer. This will ensure that your Google Analytics UA tag is configured to extract all the wonderful eCommerce data which the GTM4WP plugin is going to populate into your websites data layer. 

Next, you’ll need to click on Choose a Trigger to make this tag fire. For now, select All Pages.

You’ll end up back at this screen. Finally, click Save.  

And your new GTM tag is complete!

So now that our tag is setup and configured, we can test it out. Click the Preview button.

This will put your default Workspace into Preview mode which is a really really cool feature of GTM.

If you now open your website you should see the GTM debug panel appear at the bottom of your screen. You’ll see a number of options including Tags, Variables, Data Layer and Errors. If you click on Data Layer, you should be able to see the data that the GTM4WP plugin is producing for your websites data layer.

In addition, if you click the Tags tab you should see your GA tag is firing correctly.

Success! Now head back to GTM and click the Submit button next to the Preview button we just clicked on a few moments ago. You will see the Submit Changes screen. Again, make sure to give it a meaningful, descriptive name so you can quickly identify the workspace change in the future.

The Preview->Publish workflow of GTM is a fantastic way of first testing out new pixels and events on your live website without disrupting live users. While I’m a massive fan of WooCommerce staging environments, GTM live previews are one of the rare instances where you can get away with testing on live websites 🙂 That said, you can also configure multiple publishing environments for your GTM workspace which I would highly recommend after you’ve got comfortable with how GTM works. Go ahead and click Publish and you’ll eventually a Version summary for this publish event.

Another great feature of GTM is that you can access all your publish events via the Versions tab.

You can event choose to roll back to an earlier version of your workspace if you wish – which is incredibly useful if you end up breaking one of your tags and need to quickly revert to a previous known working state.

So GTM is now capturing all the basics of your website, let’s power on and configure GTM to capture some of the more specific eCommerce events that happen in WooCommerce.

Click on Triggers and click New

You’ll see the Trigger configuration screen. We’re going to be creating a trigger based on some custom eCommerce events that GTM4WP fires on our WooCommerce website including customers clicking on products, adding/removing products from/to the cart and checkout sessions being initiated, so let’s call this event Google Analytics – EEC Events (EEC = Enhanced eCommerce). Then click on Choose a Trigger Type and select Custom Event.

In the Event name box, copy and paste the following:

Tick the Use regex matching box. Ensure that this Trigger fires on All Custom Events

Go ahead and Save the trigger. Next, clicks Tags -> New and name your next new tag as Google Analytics – EEC Events. Again choose Universal Analytics as the tag type just like we did earlier, but this time we’ll choose Event as our Track Type. Choosing Event as our Track Type will reveal several new fields we need to enter values for to configure this tag correctly.

Under Enter Tracking Parameters, enter the following:

Category: Ecommerce helper (you can call this whatever you want – but choose a name that will make sense when viewing events in GA).

Action: This is the important one. If you type 2 opening parantheses “{{” you’ll see a number of pre-defined action variables appear. Choose Event

Repeat the exact same step for the Label field. Ensure that Non-Interaction Hit is set to False. You’ll also want to repeat our previous steps to assign your GA settings variable under Google Analytics Settings and to override the global settings to ensure that Enable Enhanced Features is set to True and Use Data Layer is checked.

Finally, you’ll need to assign a trigger. Assign the Google Analytics – EEC Events trigger we created earlier to this tag.

Go ahead and click Save.

Before we test this tag, we’re going to make another minor change to the main UA tag we setup earlier. Right now this tag is set to fire on All Pages. Most of the time that setting is fine. But there are some GTM4WP events that don’t get fired immediately as the page loads, which as a result might be missed by GTM. So, we’re going to tell GTM to not fire our main UA tag until our page document is ready. (Or in frontend engineering terms, we’ll fire our UA tag once the Document object model is ready – or DOM ready for short). This will help to ensure that interactive page events are captured correctly.

Head back to Triggers -> New.

Call it All Pages – Dom Ready and from the Choose trigger menu select DOM Ready

Click Save and then go back to Tags and open the first tag we created (which I called Google Analytics – UA). Click the Pencil icon in Triggering to edit the tag trigger.

Remove the All Pages trigger by clicking the grey remove action icon.

Then click the blue + icon and select your newly created All Pages – DOM Ready trigger.

Finally click Save. At this point I would recommend you go through a Preview->Publish workflow to ensure your tags are firing correctly. In Part 3, we’re going to show you how to check that your tags and events are firing correctly and how to understand the data you’re now collecting!


Part 3 – How to use Google Analytics to measure the growth of your WooCommerce website

Ok so now you know now you’ve chosen you preferred integration method it’s time to make sure you’ve configured Google Analytics correctly for WooCommerce.

If you’ve been brave enough to get GTM setup correctly in Part 2, let’s first make sure your tags and event names are firing correctly and the data is pouring into Google Analytics. (I’m going to assume you’ve already used the GTM Preview window to make sure you can actually see your tags firing first.) I recommend opening up 2 separate windows side by side.

In window one, open your website and start simulating what you want your customers to do. Go to your shop landing page, click on one of your Product Description Pages (PDP’s) and add to cart, go to cart, check and complete a test order.

In window two, open Google Analytics -> Real-Time -> Events. After some frontend activity, you should see something like this:

If you do, congrats – you’ve nailed your GTM setup for Enhanced eCommerce with WooCommerce!

Once you complete an order go to Conversions -> Ecommerce -> Overview

Select the current date (which you GA account is probably not setup to show by default). Once you do you should see some transaction data. (NOTE: Depending on your account, there may be a few hours delay before you actually see data in this part of GA – but in my experience I now see data in near real time).

As we’re using Enhanced Ecommerce you’ll note we didn’t need to manually configure any goals or conversion events for this data to be populated in GA – which is awesome 🙂

Next, go to Conversions -> Ecommerce -> Shopping Behavior. You should see something like this:

Boom – no we’re talkin! Now you’ve got the basis to start doing some really cool stuff in Google Analytics to understand your customers better 🙂 You can see above that my Cart Abandonment rate is 0% – how awesome would that be? 🙂 That’s just simply because I’ve just set this account up and submitted some orders immediately as part of my testing – so this is a little bit unrealistic right now – but I expect that to quickly change as we send some traffic to this website in the next few weeks.


Wrapping up

Peter Drucker is often quoted as popularising the saying, “You can’t manage what you can’t measure”. Far too many people fail in eCommerce because they don’t understand what people do when they come to their website. And we’re not talking about complex eCommerce metrics like LTC, CAC or churn (just yet), we’re talking about the basic fundamentals of any online business. Traffic, PDP views, Cart Sessions, Checkout Abandonment and Conversion rate. As an eCommerce website owner you’ll be getting to know these things inside and out. You’ll need to know how your conversion rate compares with similar websites to yours and how to find out why your rate is better or worse than your peers. But that entire rabbit hole means nothing unless the data by which you make those decisions is solid. Today, you got a rock solid Analytics platform to help in a very small way to get you on the road to success. Now good luck and get selling 🙂

11 Comments

  1. Hi,

    First of all, thanks for this “manual”. Although I’ve read and followed original “how to” couldn’t make Analytics track transactions. Now, thanks to you, it is finally working (at least it counts my test transactions :)). Now, I have a question, if I may. I am not sure if I understood it properly. We created a trigger called “Google Analytics – EEC Events” with event name beginning with gtm4wp. Then we created tag “Google Analytics – EEC Events”, BUT we didn’t choose any trigger in this tag. Is it the way it is suppose to be or was I suppose to choose “Google Analytics – EEC Events” trigger ?

    1. I had the same question! I’m pretty sure we were supposed to add the “Google Analytics – EEC Events” to the Google Analytics – EEC Events tag. It works for me.

  2. Great article! Yes, I agree with other comments that there was 1 important step missing. The New “Google Analytics – EEC Events” Tag should have the new trigger “Google Analytics – EEC Events” I put that as a trigger and it works. Besides that., all good! thank you!

  3. Does the WooCommerce analytics plug-in cover up the Wordpress analytics part of the site or do you need two plugins? Like the Google Site Kit plugin and WooCommerce analytics plugin.

  4. Hi there,

    Google Analytics – EEC Events doestn’t get fired.
    Has anyone run into the same problem?
    I think it has something to do with the category?

    Does anyone know how to solve this problem?
    Thanks in advance!

    1. The important thing to do is to change the date of the overview. By default the timeframe goes until “yesterday”

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of contents
View all guides
Free weekly newsletter
Get WooCommerce conversion, SEO, and performance tips every Friday
Shoptimizer WooCommerce Theme
Shoptimizer WooCommerce Theme WooCommerce reimagined for speed and conversions.
$50
Off

Do you want a whopping $50 off Shoptimizer for WooCommerce?

Click the button below to get Shoptimizer for only $49. (Regular price: $99).
This is a special launch offer for today only.
Get it before it is gone!