Analytics Market Chart

Set Up E-Commerce Tracking in Google Analytics

Tie transaction data to your marketing efforts to get a more rounded picture of what's working and what isn't.

Google Analytics can track online purchases to give you an idea of the true dollar value of campaigns and traffic sources. To do this, you need to enable e-commerce tracking in your profile and add some extra code to the receipt page.

Enable Ecommerce Tracking

First, edit the profile you want to track e-commerce transactions in. Edit the Main Website Profile Information box. At the bottom is a radio button to enable e-commerce tracking.

That was the easy part.

E-Commerce Code

There are three methods to the pageTracker object used to pass transaction information to Google Analytics. The first two methods expect specific parameters in a specific order. Blank values may be passed, but if any parameter is not identified, it will cause errors in the reports, or it may not send any information at all.

pageTracker._addTrans("order_ID", "store_name", "total", "tax", "shipping", "city", "state", "country");
pageTracker._addItem("order_ID", "SKU/code", "product_name", "category", "unit_price", "quantity");


This method creates a new transaction to track. It accepts the order ID, store name, order total, tax, shipping costs and shipping address.

All of the transaction-level information in the reports is pulled from this method. Google Analytics does not do any error checking or calculations to make sure that item costs add up to the specified order total, for example. Many discrepancies in ecommerce reports can be tied back to incorrect values being passed in the _addTrans() method.


This method is called once for each item in the transaction. It tracks items by the SKU or item code, so if another item is added with the same SKU, it will be overwritten. This method accepts the order ID, item ID, product name, category, unit price and quantity.

All of the item-level information is pulled from this method. Each item is tied to a specific transaction by the order ID. Also, this method is called once for each SKU regardless of quantity. It accepts the per item price and multiplies that by the specified quantity to calculate the total revenue for each item.


After all of the items have been specified for the transaction, this method must be called to actually send the information to Google Analytics. It accepts no parameters.


These pieces of JavaScript can be placed anywhere on the page after the _trackPageview() method is executed. The standard placement is immediately after _trackPageview() within the second block of tracking code.

The code can also be called in its own script block somewhere else on the page, as long as it's executed after the standard code.

Tips & Reminders

All of these transaction variables must be filled into the JavaScript code dynamically, of course. Typically this is done with server-side scripting, so it often requires the developer to get involved. Some content management systems have built-in hooks for ecommerce tracking code that make the coding more simple.

Each dollar value must be specified as either an integer or decimal. No other symbols (eg. currency symbols) are accepted.

If any variable does not apply to an item or order, it may be left blank. However, it is critical that the correct number of parameters get passed in the correct order for each method. For example, if there is no shipping cost for an order, just insert empty quotes or a zero in quotes after the tax value.

Google Analytics e-commerce code is unrelated to the AdWords conversion code. They are often both placed on the same page, but they operate completely independently. Having one set of code does not mean the other code is unnecessary or redundant.

E-Commerce Reports

When this code is in place, it will begin to populate the e-commerce reports in your profile beginning with orders placed from the moment the code was implemented.

There will be a new section titled E-Commerce in the left-hand menu. Also, traffic reports will now have an E-Commerce tab that ties information to transactions.

If these reports are still blank after 24 hours, it is because the code is implemented incorrectly. Either the code is not displaying or there are syntax errors.

If transaction and item values don't line up, it's because incorrect values were passed to the e-commerce methods.