Coding Series: Part 3 – Google Analytics Ecommerce Tracking

Leverage Archive

Leverage Archive

Woah! We've been at this a long time. What was true a year or two ago may not be true today. If you're interested in something a little more current, take a look at our recent blog posts.
Leverage Archive

Conversion tracking is important, but if you are selling multiple products at multiple price points to customers who are purchasing multiple units, it is much more tangible to track actual revenue generated from these purchases in order to determine return on advertising spend (ROAS). Ecommerce data is tracked through Google Analytics. The reporting functionality allowed with Ecommerce Tracking provides critical information into the behavior of your website visitors and is the only way to measure the sales cycle, including how many visits or days it takes for a purchase to take place.

Benefits: Ecommerce Tracking

Ecommerce reporting in Google Analytics will provide insight into which traffic sources are resulting in purchases, such as paid search or organic traffic, as well as the average value of a purchase, ecommerce conversion rate, purchases by day, revenue by geographic region, and the value of each website visit. This data can help you determine what marketing efforts are resulting in the most revenue for your business, which keywords convert best and are most cost effective, and who your target customer really is.

How It Works: Ecommerce Tracking

Ecommerce tracking works similarly to page view tracking in that data is sent to a Google Analytics server via a JavaScript Code. When a visitor submits a transaction to your server, the data is then processed. Once the transaction is processed, your server prepares a receipt to send back to the visitor. With the code correctly installed, the server will receive and process the transaction data. As the receipt is being prepared, some of the transaction data is extracted from the server and submitted to Google Analytics by way of the Google Analytics JavaScript. Simultaneously, a receipt is sent to the visitor’s browser while the ecommerce data is sent to Google Analytics. Google Analytics tracks both transaction data (transaction ID, purchase total, tax, shipping, etc.) and item data (SKU, product name, unit price, quantity).

Code Implementation: Ecommerce Tracking

There are two necessary steps in order to start tracking ecommerce transactions.

  1. Enable ecommerce reporting for your website's profile in your reports.
  1. Configure your shopping cart's receipt page to send ecommerce data to Google Analytics.

The first step is to simply enable the ecommerce reports within Google Analytics. In the profile settings of Google Analytics, you can edit the website information to specify that you have an ecommerce site, which activates the reports. There are other settings to consider if you have an international ecommerce site.

Double check that the Google Analytics code is correctly installed on your receipt page. Without this, you will not be able to track transactions because the ecommerce code is placed right within the Google Analytics JavaScript code. The JavaScript can be installed anywhere on the receipt page as long as it’s placed after the main Google Analytics page tag.

  • Sample Ecommerce Tracking Code

<script type="text/javascript">
pageTracker._addTrans(
      "order-id", // required
      "affiliate or store name",
      "total",
      "tax",
      "shipping",
      "city",
      "state",
      "country"
);

pageTracker._addItem(
      "order-id", // required
      "SKU",
      "product name",
      "product category",
      "unit price",  // required
      "quantity"  //required
);

pageTracker._trackTrans();
</script>

Technical Details: Ecommerce Tracking

If you take a close look at this code, you will see that there are three parts to the JavaScript. There are three distinct methods or actions for each section.

  • _addTrans() creates and stores all of the information about the transaction.
  • The _addItem() method adds an item to the transaction. You will need an _addItem() section for each product or SKU in the transaction. The order ID must match the same order ID in the -addTrans() method; otherwise, Google Analytics can’t tie the item to a transaction.
  • _trackTrans() method sends the data to Google Analytics by requesting the _utm.gif file once for the transaction and another time for each item in the transaction.

Google Analytics Ecommerce Tracking provides reports on total revenue, conversion rate, average order value, product overview, product SKUs, categories, transactions, visits to purchase, and time to purchase. One of the main benefits to online marketing is being able to track all of your results, and with Ecommerce Tracking, you can tie sales revenue to performance and determine the return on investment for your marketing efforts. To find out more visit: http://code.google.com/apis/analytics/docs/tracking/gaTrackingEcommerce.html. If you have any other questions about Google Analytics Ecommerce Tracking or how to install the code, please feel free to follow up with your Leverage Marketing account manager.