Spree Commerce

Try It Now

Tracking E-commerce With Google Analytics

Posted on June 17, 2013 by Wes Ketchum

Google Analytics comes with support for tracking e-commerce right out of the box. All you need to do is some basic configuration and your website will be ready to start gathering data on transactions and items sold. Spree even takes care of adding all the necessary JavaScript and makes the setup as simple as pasting a tracking ID into the Admin section of your store.

  • Google analytics may not work if you are running your app on localhost. See the section titled Testing on localhost here . To get around this try pow if you are using a Mac. Otherwise, it should work fine in production.

Set Up

The first thing you will need to do is set up a Google Analytics account if you do not already have one. Once you have an account you will need to enable e-commerce tracking for your website. This can be accomplished by logging into Google Analytics and following these steps.

1. Click Admin at the top of any screen in Analytics.
2. Use the menu in the Profile column to select the profile you want.
3. Click Profile Settings.
4. Under the Ecommerce Settings section, select Yes, an Ecommerce Site/App.
5. Click Apply.

Now that e-commerce tracking is enabled, it is time to configure your Spree store. Lets start by grabbing the tracking ID inside of Google Analytics. This can be found by clicking on Admin in the top right, and then the Tracking Info tab. The ID will be in the form UA-XXXXXXXX-X. Now go into the Admin section of your Spree store and click on the Configuration tab followed by the Analytics Trackers link at the bottom of the right side navigation. Click on the link to create a new tracker and enter your Google Analytics ID.

  • In older versions of Spree the Configuration screen will look different, however the functionality is all still supported.


Your store is now ready to start tracking e-commerce through Google Analytics. To test that everything is working, walk through the ordering process. Add an item to the cart, click Checkout, and make sure you get all the way to the order confirmation page. Once that is complete, go to Google Analytics and click on the reporting tab. On the left side navigation click on conversions, e-commerce, and then overview. You will see a page similar to the one below outlining some data gathered from your store.

  • Make sure the date filter is set to the current day on your report! The data from your store may not show up in real time. Sometimes you will have to wait a few minutes before you see a transaction.


If you wait for a couple of minutes and still do not see a transaction inside Google Analytics, check to see if these two conditions were met.

  • On the order confirmation page in your Spree store, make sure the Google Analytics JavaScript is present. It should be located at the bottom of the page source and begin with

var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);

If the Javascript is not present, be sure you are still including the spree/shared/google_analytics partial in your application layout.

  • Use the developer tools in your browser to inspect the Spree order confirmation page. On the network tab make sure there is a _utm.gif resource at the bottom of the page. If you do not see that than your data is not being sent to Analytics and is most likely a problem related to using localhost as mentioned previously.

That’s all there is to it. Please leave a comment with any questions or problems. Enjoy!