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.
Yoast SEO plugin breaking some Analytics installs: see the Yoast Troubleshooting section.
If you’re using the Neighborhood WordPress theme, make sure you address the recent issue described here.
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 and then . Then, .
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.
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.
Fill out the Account Name as appropriate, then click .
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 .
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).
Navigate to the Profile Settings.
Change all settings as appropriate, but be sure to turn on eCommerce tracking and click .
!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.
Go ahead and navigate to your Goals tab and click .
For this article, we’re going to create a Goal and immediately disable it. So in the section, choose and click .
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.
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.
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
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.
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!
Leave a Reply
84 Comments on "WooCommerce and Google Analytics eCommerce setup"
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.
Hey Simon. I’m running latest WooCommerce, 2.0.12. I’ll take a look at 2.0.10.
It looks like Woo fixed a bug in class-wc-google-analytics.php sometime between 2.0.10 and 2.0.12 on line #217. In 2.0.10, WooCommerce was sending an improper order ID to Google Analytics. Upgrading to 2.0.12 should help you.
Hey,
I had previously set my site analytics to ‘Universal’ how do I change this to ‘classic’ without deleting and recreating my account?
Hi, Joey.
Very useful post, thank you!
I´ve got a question: How do I put both analytics IDs to work? I´m using the Yoast Google Analytics, may I just put UA-XXXXXX-X;UA-XXXXXX-X ? Same in the Woocommerce Integration setup?
Thank you
Douglas,
You should be able to use one Google ID in your Yoast setup and a different Google ID in WooCommerce -> Settings -> Integration -> Google Analytics.
Does that answer your question?
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
Hi JB.
Yoast’s Analytics gives me many additional features for tracking pages. I can exclude certain roles from being tracked; add custom variables; track post types and categories separately; etc. Of course, I could do all of this by adding adding code to my theme. But the Yoast plugin makes it a lot easier.
And yes, I’d recommend it.
Thanks for this Joey! I’ve just followed your Yoast fix instructions, will report back after a couple of sales have come through.
good artical for me. thank you.
Thanks for your comment, Alüminyum. Glad you found it helpful.
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!
Thanks Jesse. Glad you found it helpful and I appreciate your comments on the blog.
Hi Joey
Still no joy with eCommerce tracking even after enabling the excerpts. Thanks for all your suggestions so far.
Simon,
Can I contact you privately about your site? I’d be happy to take a look.
Great article, if I hadn’t found this I would have been pulling my hair out all week.
Awesome. Thanks Ian.
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.
Hi Ryan.
I assume you saw the troubleshooting tips in this blog article? And yes, there is a delay. Have the transactions shown up in Analytics yet?
Hey Ryan, make sure your /order-received/ page isn’t under /checkout/order-received/
Matt, I’ll email you and we’ll get this figured out.
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
Excellent post! Where exactly in the functions.php file would you add “remove_action( ‘woocommerce_thankyou’, ‘woocommerce_order_details_table’, 10 );” ?
Hi Jonathan,
Within the function.php file, the line of code can appear anywhere after the opening
<?php
.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?
Jonathan, I’ll email you directly.
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
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?
Hi, tks for your reply
because I’m using the Google Analytic for wordpress plugin
so if I use two ga ID, is that one ID for blog will count the woocommerce pageview?
for my understanding, the plugin I use will insert all tracking code into every page??
also, if I use two tracking ID, should I leave the “insert tracking code into footer” checked in woocommerce integration section?
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,
Please contact me through and send me your site’s url. I’ll take a quick look.
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!
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 ?
Hi Alex. I’ll be following up with you directly.
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!
Diego, I’ll be contacting you privately.
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
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
Good point – thanks Colin. I’ll update the tutorial.
Thanks for pointing out.. 🙂
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
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
Hi Dan.
You are correct: WooCommerce sends the transaction to Analytics from the ‘Order Received’ page. If your customers are not redirected back to your site after completing the transaction on PayPal, the transactions will not be sent to Analytics.
I’ve been developing a set of tools to enhance WooCommerce’ use of Analytics, though, this scenario had not occurred to me. It’s something I’ll look into. Wish I had a better solution for you right now.
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.
@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.
Is there a time schedule for when Woocommerce will support Universal Analytics for ecommerce tracking?
I’m looking for the answer to this myself.
We’ll then I’m not the only one who can’t find info on this. I’ll try if I can code a plugin that replaces the old ecommerce tracking code of WC with a new version for Universal Analytics. I’ll ley you know it I get it done.
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!
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
Maggie,
The code you posted is part of the script that sends the tracking info to Google, so I’m not exactly sure what you mean. I’ll email you to follow-up.
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.
budakhan,
If you’ve added the Analytics code to the Canvas settings, you probably shouldn’t check “Add tracking code to your site’s footer..” (in the WooCommerce settings). This will possibly result in Analytics adding two hits for each page view. However, you *should* check “Add eCommerce tracking code to the thankyou page” if you intend to track WooCommerce eCommerce transactions. Make sense?
Thanks for the quick reply. Ok, that sounds great. And this might be a really dumb question. But for some reason if changing the settings in WooCommerce> Settings> Integration> Google Analytics doesn’t work, can I just take out the Google Analytics ID, save the settings again, and everything will be back to how it was? Just looking for an exit strategy 😉
Joey. This article is awesome I followed your steps and took your advice. Everything works perfectly. Thank you.
Glad to hear it! Good luck.
If you remove the Analytics ID from the WooCommerce settings (or uncheck the “Add eCommerce tracking code…”), no eCommerce data will be sent to Google. However, any data previously sent to Analytics will still be in Analytics, i.e. nothing gets deleted from Google Analytics.
If you happen to run into trouble or just can’t seem to get everything working, you can also consider my Google Analytics services.
Good luck!
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.
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!
Disregard that last question, I figured out where to put it!
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!
Oeds,
You’re on the path to fixing this, but it will require a little code troubleshooting. Please contact me here; I’ll follow up with you.
I followed all the steps but it doesn’t work :/ , someone help me please
Hi yusuf.
Please contact me here with some info about your website. I’ll see if I can provide you with some guidance.
Hi Jesper,
I took a quick look at your site and I don’t see anything wrong with it. Thus, the problem is likely in one of the theme files or more likely, a plugin is causing the issue. I would suggest uninstalling each plugin (if you can) to determine which one is causing the issue. Or, I am available to help you troubleshoot the problem: https://xd3v.com/shop/woocommerce-google-analytics-implementation/
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!
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/
Wow. Ya. I’m baffled.
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?
Hi Juanma, I’ll follow up with you directly.
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
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.
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?
Not sure how I missed this comment, but for others coming to this page: When you’re logged into WordPress, eCommerce data is not sent to Google Analytics.
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
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