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 + "google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try { var pageTracker = _gat._getTracker("UA-XXXXXXX-X"); pageTracker._trackPageview(); } catch(err) {}
</script>
[/code]

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 “https://www.jxtgroup.com/thankyou.html” 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-Funnel-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 + "google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E"));
</script>

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

// Main Order Info //
pageTracker._addTrans(
"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 //
pageTracker._addItem(
"1234", // Order ID
"DD44", // SKU
"T-Shirt", // Product Name
"Green Medium", // Category
"11.99", // Price
"1" // Quantity
);

pageTracker._trackTrans();
} catch(err) {}
</script>
[/code]

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

Comments (10)

  1. Q-Man:

    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. Google Analytics:

    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.

    1. Michael J. Kaye:

      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. Panasonic 3D Glasses:

    Okay….

    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.

    So….

    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.

  4. Christy:

    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?

Comments are closed.