- 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.
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.
var _gaq = _gaq || ;
- 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!