WooCommerce and Google Analytics eCommerce setup

Introduction

Tracking your WooCommerce sales in Google Analytics can be hugely beneficial to understanding your business. By enabling eCommerce tracking, Google Analytics will provide a wealth of information about your visitors, how they found your products, how long it took them to buy, how much you’re making from each traffic source, how much each visit is worth, etc, etc. However, setting up your environment and getting everything working correctly can be a bit tricky.

This article will help you setup eCommerce tracking for WooCommerce and Google Analytics and provide some very important troubleshooting tips in case your already running into problems. If you’re already setup and things just aren’t working, be sure to read the section on Setting Goals.

Need WordPress and WooCommerce Hosting?

Our 100% favorite host is Lightning Base. Blazing fast, great support, excellent price.

Lightning Base Web Hosting
Update July 24, 2013
Yoast SEO plugin breaking some Analytics installs: see the Yoast Troubleshooting section.
Update August 16, 2013
If you’re using the Neighborhood WordPress theme, make sure you address the recent issue described here.
Update December 15, 2013
The Simple Facebook Connect plugin, version 1.5 (and maybe others) can break Analytics tracking for WooCommerce. If you’re using that plugin, please disable it and run a test transaction, along with following the rest of this tutorial.

Setting up eCommerce in Google Analytics

We’re going to focus on setting up eCommerce; however, we’ll go through the steps of setting up Google Analytics because there are some important pieces of information in the process.


Log into your Google Analytics account and click Google Analytics Home Button and then Google Analytics Admin Button. Then, New Account Button.


Tracking Method

When you create your account, you’ll want to choose Classic Analytics. As of now, Universal Analytics is still in beta and WooCommerce doesn’t use it.


Google Analytics Web Property Settings

Fill out the web property form according to your own domain. We’re going to use Gotta Salsa’s staging domain (a website ran by XD3V) for this article.

!Important Select an Industry Category. This is required to create Goals. Why does this matter??? See the section on Setting Goals below.

Also, be sure to select https if your entire site runs under SSL. Selecting SSL is not recommended if only your shopping cart runs under SSL.


Naming your account

Fill out the Account Name as appropriate, then click Get Tracking ID Button.


GA Subdomain Settings

The next screen will bring you to the Tracking Info for your new web property. If you’re using sub-domains, be sure to turn them on and click Save Button.


GA Profiles Tab

Next we’ll enable the eCommerce settings. Go to Profiles tab and select All Website Data (or whatever you named it on the previous page).


Profile Settings Tab

Navigate to the Profile Settings.


eCommerce Site Option

Change all settings as appropriate, but be sure to turn on eCommerce tracking and click Apply Button.


!Important Setting Goals

At this point, you’d think you were done setting up Google Analytics. But you’re not! As of this writing, there seems to be a bug (or a feature?) in Analytics that’s only briefly addressed on this Google support doc. The main takeaway is this:

You must setup at least one Goal in order to see your eCommerce transactions inside Google Analytics.

You don’t even need to enable the Goal! In fact, for my staging site, I don’t want any Goals. But you have to at least create one. Because this seems to be a bug/feature, I can’t speak to its longevity.

Goals Tab

Go ahead and navigate to your Goals tab and click Create Goal Button.


For this article, we’re going to create a Goal and immediately disable it. So in the Goal Setup section, choose Custom Option and click Next Step.


Goal Settings

Name your Goal whatever you want. You should probably give it a name that you could use later because you have a limited number of goals you can create. But for this article, BS Goal sounds about right. Select Destination, then click Next step.


Goal Details

We’re going to stick with the WooCommerce default thank-you page for this Goal. Does it matter? Probably not because we’re just going to disable this goal as soon as it’s created. However, because this is a bug, I can’t say if it really matters or not. We’re going to play it safe.

Click Create Goal.


All Goals

Now, disable the Goal. Awesome :-/

For help beyond this article, you can also refer to Google’s help page.


This next section describes the straightforward WooCommerce setup. So before you leave Google Analytics, be sure to copy the the Property ID. It looks something like UA-XXXXX-X.


WooCommerce Setup

Jump into your WordPress Admin and navigate to WooCommerce -> Settings -> Integration -> Google Analytics


WooCommerce Settings

Enter the Google Analytics ID that you copied from your Google Analytics web property. Again, this ID will look something like UA-XXXXX-X.

Set the domain name as you set it in Google Analytics. As noted, this is optional and can depend on your shop’s domain or sub-domain. For this article, we’re sticking with the same domain we entered in Google Analytics when we created the web property.

We’re removing “Add tracking code to your site’s footer…” because we’re already running Yoast’s Google Analytics for WordPress. If you’re not already running an Analytics WordPress plugin, leave the box checked.

Check the last two boxes as indicated and Save Changes.


Troubleshooting

This essentially completes the eCommerce setup for Google Analytics and WooCommerce. However, there are some important troubleshooting tips to consider:

  • Google Analytics Debugger, a Chrome browser extension, can be a huge help in determining if WooCommerce is sending the proper eCommerce data to Google Analytics. Once installed, open the Javascript console (Control-Shift-J on Windows and Linux; Command-Option-J on Mac) and run a test transactions. When you arrive at your WooCommerce “Thank You” page, look for _addTrans and _addItem in the debugger’s information. That will be the indication that transactions are being sent to Google.
  • Depending on your WooCommerce cart setup, you might need to enable subdomains in Google Analytics as we did earlier in this article. Meaning, if your website is http://example.com but your cart is http://mystore.example.com, you’ll need to enable subdomains under Tracking Info.
  • When creating your Google Analytics web property, you’ll probably have to use Classic Analytics instead of the new Universal Analytics until WooCommerce adds support for the new script.
  • !Important. Make sure that you designate an Industry in the Google Analytics setup.
  • Make sure that WooCommerce -> Settings -> Integration has ‘Add eCommerce tracking code to the thankyou page’ is checked.
  • If your WooCommerce products are single purchase only (meaning, your user is taken directly to the checkout after adding to cart – e.g. subscriptions), you might not see the ‘Add to cart’ event recorded in Analytics. I suspect there is a bug in WooCommerce – yet to be verified. However, the purchase transaction will still show in Analytics.
  • If you’re conducting test purchases while logged-in as the WP admin, those purchases won’t show up in Google Analytics.
  • If you’re running test purchases while using a browser extension such as Google Analytics Opt-out Add-on, the transactions won’t show up in Google Analytics.
  • I have yet to see Google Analytics real-time conversion work. However, the conversion will still show in the eCommerce report. So don’t get discouraged just because you’re not seeing real-time eCommerce transactions.
  • !Important. Read Setting Goals in this article. As of now, you have to have at least one Google Analytics Goal (even if it’s disabled) before your Analytics reports show your eCommerce transactions.
  • !Important. It can take ~24 hours for results to show in Google Analytics reports. Especially if your Analytics account is new. Sometimes data will show in under and hour, but you never know.
  • While anxiously awaiting your eCommerce transactions to show up in Google Analytics, make sure you’ve set the date to include TODAY 🙂
  • Data will not refresh in all Analytics eCommerce reports at once. The reports seem to get refreshed at different times, no matter now many times you click tiny little “Refresh Report” link.
  • In fact, even the data items within a single report will refresh at different times. For example, in the Product Performance report, Quantity might refresh twenty minutes before Product Revenue. Frustrating, I know.
  • *NEW* It appears that WooCommerce also fixed an issue as of 2.0.12. Prior to that, an improperly formatted Order ID was being sent to Google Analytics. So in addition to the above tips, make sure you’re running at least WooCommerce 2.0.12.
  • If you’re still experiencing issues after following this article, feel free to contact us here.

Troubleshooting Yoast’s WordPress SEO

*NEW* As of this writing, Yoast’s WordPress SEO Plugin (version 1.4.11 and later) is breaking some Google Analytics eCommerce implementations. At this time, we’re still troubleshooting the issue. But we have a fix.

The issue rears its head when a theme (or another plugin) has disabled page excerpts or no excerpt exists. Why does this matter? The SEO plugin is active on your WooCommerce “Thank You” page. When the plugin tries to do its job, it attempts to grab the page’s except and place it into the Facebook meta tag “og:description”. If the excerpt can’t be found, a portion of the page’s content is inserted into the meta tag – including WooCommerce’s Google code.

Fix the problem.

WordPress Screen Options

In the WordPress admin, edit your WooCommerce “Thank You” page (Order Received by default) and see if your Screen Options includes “Excerpt”. If so, make sure it’s checked and skip the next step. If not, you’ll need to add some code to your functions.php file.

If your Screen Options do not include “Excerpt”, add the following code to your theme’s functions.php file. This code will enable excerpts for pages:

add_action('init', 'my_custom_init');
     function my_custom_init() {
     add_post_type_support( 'page', 'excerpt' );
}

Once that’s done, edit your “Thank You” page and again make sure that Excerpt is checked in your Screen Options.

While editing the “Thank You” page, scroll down to the Excerpt section and enter something like “Thank you for your order!”. Save the page.

That’s it! Re-test your Analytics transactions. But keep the other troubleshooting tips in mind when you test!

Troubleshooting Neighborhood Theme

*NEW* We discovered an issue with the Neighborhood WordPress theme after assisting one of our readers with their setup. If you’re using the Neighborhood theme, save yourself some time by addressing the possible issue described below (along with following the rest of this turorial).

In your Neighborhood theme directory (the parent, not the child theme), open the file
/wp-content/themes/neighborhood/woocommerce/checkout/thankyou.php
On or around line #74, you should see the following code:

<?php do_action( 'woocommerce_thankyou_' . $order->payment_method, $order->id ); ?>
<?php //do_action( 'woocommerce_thankyou', $order->id ); ?>

If you see that the second line contains “//”, you have a problem. If the line doesn’t contain “//”, you’re in the clear (on this issue, at least).

The fix is simple, but is slightly different depending if you’re using a child theme or not.

If you’re not using a child theme, simply remove the “//”, save the file, upload to your server. You’re almost done, but not quite.

If you are using a child theme, you’ll need to save a copy of the file to your child’s directory which should be something like
/wp-content/themes/neighborhood-child/woocommerce/checkout/thankyou.php
After saving the file, remove the “//”. Re-save and upload the file.

Whether you’re using a child theme or not, you’ll want to make one more change…

After fixing the thankyou.php file, you’ll be left with a fairly ugly order summary on your Thank You page. The order summary isn’t necessarily bad, but it doesn’t go well with the Neighborhood theme and it wasn’t intended by the theme author. So, to fix the issue, you’ll need to add one line of code to your functions.php file.

If you are not using a child theme, open
/wp-content/themes/neighborhood/functions.php
If you are using a child theme, open that theme’s functions.php file. In both cases, add the following line of code, then save and upload:

remove_action( 'woocommerce_thankyou', 'woocommerce_order_details_table', 10 );

This line will remove the order summary from the Thank You page.

Done!

Make sure you follow the rest of this tutorial and the other TROUBLESHOOTING TIPS. Good luck!

Hosting for WordPress and WooCommerce?

We recommend Lightning Base. Blazing fast performance and superior support at a fraction of the price. Seriously, these guys are great!

Lightning Base Web Hosting

Leave a Reply

84 Comments on "WooCommerce and Google Analytics eCommerce setup"

Notify of
avatar

Sort by:   newest | oldest
Simon
Guest
Simon
3 years 4 months ago

Hi Joey

Thanks for these tips. Which version of WordPress & WooCommerce are you working with? I have goals set up on my site, and had ecommerce tracking working just fine until I recently upgraded to 2.0.10. Reverting to 2.0.6 seems to have fixed the issue.

Colin
Guest
Colin
3 years 4 months ago

Hey,

I had previously set my site analytics to ‘Universal’ how do I change this to ‘classic’ without deleting and recreating my account?

JB
Guest
JB
3 years 4 months ago

Joey,

Great article.

What are the reasons for using Yoast Analytics as well as the integrated analytics?

Would you recommend using Yoast Analytics as well?

Thanks,
JB

Simon
Guest
Simon
3 years 4 months ago

Thanks for this Joey! I’ve just followed your Yoast fix instructions, will report back after a couple of sales have come through.

Alüminyum Boru
Guest
3 years 4 months ago

good artical for me. thank you.

Jesse M.
Guest
3 years 4 months ago

Hey Joey, Found you off here http://wordpress.org/support/topic/google-analytics-ecommerce-tracking-on-working-with-woo-commerce helping out Garyhoody. I was also having problems with hooking up analytics with woocommerce + mayashop + yoastSEO and you seriously made the walkthrough a breeze. Thank you for writing such a great article!

Simon
Guest
3 years 4 months ago

Hi Joey

Still no joy with eCommerce tracking even after enabling the excerpts. Thanks for all your suggestions so far.

Ian
Guest
3 years 4 months ago

Great article, if I hadn’t found this I would have been pulling my hair out all week.

Ryan
Guest
3 years 4 months ago

Strangely, I see the specific woocommerce vars you mention being sent to GA via the debugger but I still don’t see anything in my GA portal. I tried turning the /order-received/ goal on and off and running transactions. Is there a delay? If not, are there any other troubleshooting tips I should consider. Excellent article though…got me 95% of the way.

Andrew
Guest
2 years 9 months ago

Hey Ryan, make sure your /order-received/ page isn’t under /checkout/order-received/

Matt
Guest
3 years 3 months ago
This is driving us crazy! 🙂 One day, our conversion tracking just ‘stopped working’. We had changed themes, so thinking that was it, switched back, but no difference. We’ve followed your steps above, three times. Even going as far as creating an entirely new analytics property, just to ensure everything was setup as yours is. This still didn’t show us conversion data. Disabling, or Enabling the YOAST SEO plugin has no effect. We ensured the excerpt was created on the thank you page. We’ve also installed the debuggers, but the _addTrans and _addItem items do not show up. We tried… Read more »
Bruno Cardoso
Guest
3 years 3 months ago

Hi Joey,
Very nice blog post. I did everything you pointed out, however it is still not working =/
Can you help me further? I posted an issue here https://github.com/woothemes/woocommerce/issues/3647

Jonathan
Guest
3 years 3 months ago

Excellent post! Where exactly in the functions.php file would you add “remove_action( ‘woocommerce_thankyou’, ‘woocommerce_order_details_table’, 10 );” ?

Jonathan
Guest
3 years 3 months ago

Thanks for the response Joey! One more question! I am using a child theme for Neighborhood and it doesn’t have its own functions.php file. Should I copy the main theme’s functions.php file, make the addition and then drop it in the child theme’s folder?

Ankit
Guest
Ankit
3 years 3 months ago

Hello Joey,
I’m having a problem with my WooCommerce setup. It’s unable to perform Google Analytics Ecommerce tracking. Can you help?

Thanks
Ankit

Jeffrey
Guest
3 years 3 months ago

Hi, my site is running a blog, and now we want to add a EC site using woocommerce

I already use Google Analytics for WordPress, can I use the tutorial here?

and can I separate these two (blog & ec) in analytics?

Troy
Guest
Troy
3 years 3 months ago

First, THANK YOU for the article! You seem to be the only one who even acknowledge that this issue exists.

Second, HELP! Haha, I’ve done everything you’ve suggested without success. The GA debugger does NOT show either _addTrans or _addItem

I’m on WP version 3.6, WooCommerce 2.0.13 and WordPress SEO 1.4.14.

Thanks!

Troy
Guest
Troy
3 years 2 months ago

Hey Joey, I tried contacting you through the contact form but haven’t heard back. Are you able to take a look at my site and see if there’s anything glaringly wrong? Thanks for the help!

Alex
Guest
Alex
3 years 2 months ago

Hey Joey,

Thank you very much for your article !

I’ve followed each point you mentioned, I’ve found Addtrans and additem in debugger but I have still nothing in my google analytics…

Do you have any idea why it’s not working ?

Diego
Guest
Diego
3 years 1 month ago

Hello Joey!
First of all, I’d like to thank you for this article. It’s great and I’m spreading the word.
I followed all the steps in this article (a few times) but, still, Analytics refuses to receive the data from Woocommerce despite GA Debug saying that the information is being sent (from what I understand).
Any idea what might be happening?
Thank you!

Brent Mail
Guest
3 years 1 month ago

Hi Joey – great article and very easy to follow – Thanks!

I’m having the same problems and looks like I have gone through all the steps but still no luck.
I’ll send you a private message – hopefully you can help me.
I’m running woocommerce 2.0.13 on Definition 1.3.3

Cheers,
Brent

Colin M
Guest
Colin M
3 years 1 month ago

Hi Joey,

Thanks for this article. Something that I noticed about my site that was different from yours is that my Order Received page is a child of the Checkout page. So the URL is /checkout/order-received/ for my site when setting up that “BS Goal.” That is the default for WooCommerce now. The goal in your example is “BS” but for people that want to make an actual goal and use the order received page as the destination, you might want to update this to not confuse people.

Cheers!
Colin

Chirag
Guest
2 years 11 months ago

Thanks for pointing out.. 🙂

Dan
Guest
3 years 1 month ago

Hi Joey, I’m finding that not all transactions are being recorded. I can’t seem to see a pattern why. Is this common… any tips on what I could try? I’m using the Abundance theme By Kriesi.

Cheers
Dan

Dan
Guest
3 years 1 month ago

Ahh wait, just ran some more test transactions… my credit cards are processed via Paypal external to the website. If the customer doesn’t choose to return to my site after completing the transaction on Paypal, then it’s not recording the transaction in Analytics.

Does that sound right? The customer must view the final ‘Order Received’ page for it to be tracked in Analytics? If so, and many transactions wont be tracked, that makes any reports basically useless.

cheers
Dan

Sean
Guest
3 years 1 month ago

Great article it help us troubleshoot our Google Analytics goals.

WC Version: 2.0.18
Function version 1.1.15 by WooThemes

If you have All in One SEO Pack Pro by Michael Torbert version 2.1.4 do not CONNECT your Google Analytics it will cause error in the thankyou page /order-received/ thus confusing Analytics goals. Installing GOOGLE TAG ASSISTANT can help you troubleshoot and analyze your codes.

Kenold Beauplan
Guest
3 years 1 month ago

@Dan, you can setup PayPal’s Return URL (in PayPal admin) to send users back to http://www.yourwebsite.com /checkout/order-received/ after completing a transaction. You must enable Auto Return in PayPal admin before you can do that though.

Mikkel
Guest
Mikkel
3 years 1 month ago

Is there a time schedule for when Woocommerce will support Universal Analytics for ecommerce tracking?

Maggie
Guest
Maggie
3 years 13 days ago

Hi Joey, in my case the ecommerce tracking code from WooCommerce get broken with tags like this:

var _gaq = _gaq || [];
_gaq.push(
[‘_setAccount’, ‘UA-xxxxxx-y’],
[‘_setCustomVar’, 1, ‘logged-in’, ‘no’, 1],
[‘_trackPageview’]
);
_gaq.push([‘_addTrans’,
‘#2037’, // order ID – required
etc.

Any idea what’s causing this?

Thanks!

Maggie
Guest
Maggie
3 years 13 days ago

Hm, it didn’t appear correctly in my initial comment, here it is again:

var _gaq = _gaq || [];
_gaq.push(
[‘_setAccount’, ‘UA-xxxxxx-y’],
[‘_setCustomVar’, 1, ‘logged-in’, ‘no’, 1],
[‘_trackPageview’]
);
_gaq.push([‘_addTrans’,
‘#2037’, // order ID – required

budakhan
Guest
budakhan
3 years 8 days ago

Awesome, awesome article. One thing is giving me hesitation however. I’ve dropped the Google Analytics code into Woo Canvas and am getting standard analytics just fine. Do you think it would be a problem if I checked “Add tracking code to your site’s footer”? Or should I leave that unchecked? Canvas is kind of like a third party right? But kind of not.

Thanks again.

Paul
Guest
Paul
3 years 6 days ago

Just a quick question I am still hung up on. Do I need to manually add the whole GA tracking code to my footer.php if I add the tracking code to the woo integration tab? Should I take the code it out of my footer and just check the woo “add to footer” box? Does having it in the footer.php and in the woo tab screw up the tracking in GA? Thanks, sorry if this is redundant but its the one answer I cant seem to find.

Paul
Guest
Paul
3 years 6 days ago

And is there somewhere specific I need to put:

add_action(‘init’, ‘my_custom_init’);
function my_custom_init() {
add_post_type_support( ‘page’, ‘excerpt’ );
}

In my functions.php? No really sure where to drop it, and am not really confident enough just dropping it in there anywhere. Thanks again!

Paul
Guest
Paul
3 years 6 days ago

Disregard that last question, I figured out where to put it!

Oeds
Guest
2 years 11 months ago

Hi,

Great article! Unfortunately it doesn’t work for me yet.
I guess it’s going wrong in the yoast seo plugin.

When reading the troubleshooting i checked the excerpt and put it on and off. The google code didin’t show up both times in <meta property="og:description" like mentioned in the troubleshoot.

However i got it in og:image like this.

This doesn’t seem right. right? How do i get it out there?
I already tried filling in an image, but then it just puts an extra line in with og:image

This is the thank you url: http://www.villa-vrolijk.nl/bestelling-ontvangen/

Thanks for your reply!

yusuf
Guest
yusuf
2 years 11 months ago

I followed all the steps but it doesn’t work :/ , someone help me please

Jesper
Guest
Jesper
2 years 10 months ago
Hi great guide, but I’m still having issues with my eCommerce tracking. I’m running WooCommerce 2.0.19, I’m having Yoast SEO plugin installed and inserted the extra code to get the Excerpt like you’ve said, no problem. But when I’m completing an order only the regular _trackPageview is being sent to Google, and I can’t find any trace of the eCommerce tracking code even though it is setup just like you’ve explained. I’m at a total loss here. The site is hundeslottet.dk and the theme is build upon the WP roots theme, my experience with word press is somewhat limited to… Read more »
Sieghart
Guest
2 years 9 months ago
Hi Joey, Thanks for this nice step by step guide! But unfortunately even after following your guide I can’t get it to work…. :-// When I set up goals (I’ve set up 2 goals for ‘order-received’ page in my sites’ 2 languages) and I leave them on in GA, they work fine, and register each sale, but only that, no more info. In your guide you say it’s important to create a goal, but turn them OFF. When I do that, there’s no improvement, still no ecommerce tracking. my woocommerce site is huahuafu.com/shop Any idea on what I’m doing wrong?… Read more »
andrew
Guest
andrew
2 years 9 months ago

Hello, thanks big time savor. Now, after updating to the most recent version of WooCommerce the “Integrations” tab is gone? And my conversions completely stopped tracking upon this update?

Do you know how to get ecommerce tracking back up with the newest version of woocommerce, without the integration tab?

thanks!

budakhan
Guest
budakhan
2 years 9 months ago

They took it out!
And then they have this plugin. Why they did this IDK. But I’m installing it now to see if it works or not.

http://wordpress.org/plugins/woocommerce-google-analytics-integration/

Juanma
Guest
2 years 8 months ago

Hi there! Thanks for this great tutorial. I follow all the steps, but everything was already up and running. My only problem is that GA is not tracking events related to ecommerce. All transactions are fine, but I can´t see if people is adding to cart, and so on… so I don´t have information enough about the purchase funnel. Did you notice something about that?

seo serices in hyderabad
Guest
2 years 4 months ago

hy i see your blog its fantastic , i have done everything you told about this article but my tracker not installed , my website display the view page source code.its same as my snippet code show me. i check every thing almost 3 to 5 time but its always show that your tracker not installed.what should i do next that my tracker show installed

Verin
Guest
2 years 4 months ago

I use woo, but can’t track the orders before. Thank you for your post, and now I can track them now, very detailed help.

jaz
Guest
jaz
2 years 3 months ago

Using GA debug, it looks like all data is populating fine when logged out. When logging in, that same data doesn’t seem to appear. Any insight on this?

Jens Nymoen
Guest
2 years 1 month ago

Hi

This looks like a great tutorial, which I find hard to find for Woocommerce. I have some trouble.
– I don’t seem to get any funnel, how do I setup this and which woocommerce pages should be there. I have tried many things but nothing works.
– Some of my products are added with the total price instead of unit price. like buy 3 pcs for total 300, it then shows 900 instead. Even the unit price is 100.

Hope to can guide me here.

WBR
Jens Nymoen

Adrian
Guest
1 year 6 months ago

Hey man,

i installed the latest woocommerce, but i do not have the integration tab like your picture has?

i remember the older version has the integration but this new one doesnt have

how to do the ecommerce tracking?

thanks

wpDiscuz