Track Sales With Google Analytics E-Commerce Tracking

Google Analytics is a very powerful and free tool. It’s as good (if not better) than some of the enterprise tracking tools out there.

Standard Tracking

The standard Google Analytics tracking pixel will get you all the basic data such as visitors, page views, referring source and keywords. This is essential for any website, especially an online retailer.

You can get the code for this sample Google Analytics standard tracking pixel from Analytics Settings > Profile Settings > Check Status (top right), or copy from here and replace the UA-XXXXXXX-XX with the ID from your account on the same page.

[code lang=”js”]
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src=’" + gaJsHost + "’ type=’text/javascript’%3E%3C/script%3E"));
<script type="text/javascript">
try { var pageTracker = _gat._getTracker("UA-XXXXXXX-X"); pageTracker._trackPageview(); } catch(err) {}

Setup Conversion Goals

The next thing you’ll want to do is set up conversion goals. For an ecommerce site, the primary goal will be a customer’s purchase. However, you can set up additional goals like customers who used the contact form or signed up for your newsletter or mailing list.

You can set up a Goal under Analytics Settings Profile Settings Goal Settings. In the first section fill out the requested fields as follows (see screenshot below):

  • Active Goal — Yes
  • Match Type — Generally use Head Match
  • Goal URL — For the goal page “” enter “/thankyou.html”
  • Goal Name — This can be anything you choose
  • Case Sensitive — Better leave unchecked unless you know what you’re doing
  • Goal Value — If your goal has a set price, enter it here. Otherwise, leave it at 0.0.

Google Analytics -- Goal Set Up Section 1

In the next section, you will need to outline the pages that a consumer must go through to place an order. I have used the page names from Magento Commerce as an example. The first step will generally be required, the best place to start will be your shopping cart page. You can assign any name to these pages.


Google Analytics -- Goal Set Up Section 2

In Google Analytics, there is a section with many reports on your goal funnel. you can see your conversion rate as well as a Funnel Visualization. This will also help you see where people are dropping out of you checkout flow.

E-Commerce Tracking

Tracking your sales is by far the most important part of this guide. Without knowing where to attribute your sales you won’t know where your ad spend is being effective and where you you are losing your pants. Google Analytics’ ecommerce tracking allows you to track data such as purchase quantity, items ordered, product category, sale referring source and much more.

Here is a sample Google Analytics ecommerce tracking pixel. Note the comments in the JavaScript code. There are two parts, one for the order info (order number, total, city, state zip etc…) and one for the product information (model, description, quantity, price etc…) — the second part must be looped once for each item in the order. Ahain, make sure to replace “UA-XXXXXXX-X” with your ID.

[code lang=”js”]
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src=’" + gaJsHost + "’ type=’text/javascript’%3E%3C/script%3E"));

<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-XXXXXXX-X");

// Main Order Info //
"1234", // Order ID
"Mountain View", // Affiliation
"11.99", // Total
"1.29", // Tax
"5", // Shipping
"San Jose", // City
"California", // State
"USA" // Country

// Loop Once Per Item //
"1234", // Order ID
"DD44", // SKU
"T-Shirt", // Product Name
"Green Medium", // Category
"11.99", // Price
"1" // Quantity

} catch(err) {}

Note: One limitation of most analytical software is the inability to track phone sales.

10 Comments to "Track Sales With Google Analytics E-Commerce Tracking"

  1. Reply
    August 20, 2009 at 11:20 PM

    Thanks for the post. I think it’s a lot simpler to set up tracking than it seems to most people at first glance.

  2. Reply
    Google Analytics
    January 7, 2010 at 3:58 AM

    I am confused. When did the word pixel come to mean tracking code? Why do people use pixel instead of saying tracking code, or am I missing something.

    • Reply
      Michael J. Kaye
      January 7, 2010 at 10:29 AM

      Generally tracking codes utilize the placement of a single pixel image on the landing pages. When the landing page calls that image file, it tracks a visit/conversion. I think that people just started calling it a tracking pixel after a while.

  3. Reply
    Wenhui JI
    October 30, 2010 at 1:57 PM

    Thanks for the article. Goal Setting is important for the following analysis.

  4. Reply
    Panasonic 3D Glasses
    December 7, 2011 at 3:12 PM


    Let me ask you think….

    I am tracking sales through the ecommerce section.

    But when one person buys 5 things why does it not track it.


    Someone comes to my site and buys 2 pair of green widgets, why does only one green widget sale, show up in ecommerce?

    Any help is appreciated.

  5. Reply
    March 13, 2014 at 2:06 AM

    Mike post was great and really it was useful for me. But Still i had a doubt in implementing this code..
    After enabling the google API code in Magento backend, is it compulsory to add this code in the thank you page to track the “product performance” in analytics?

  6. Reply
    November 13, 2014 at 12:35 AM

    Working like a charm. Thank you for your effort on this article.

Trackbacks for this post

  1. Track Goals In Google AdWords With Google Analytics Tracking Pixel » E-Commerce Circle
  2. How To Test Google AdWords Keyword Positions In Analytics » eCommerceCircle
  3. How To Track Magento eCommerce Sales In Google Anayltics - eCommerceCircle

Leave a comment

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