This is part 2 in my series on Google Analytics e-commerce tracking. In part 1 I described, at a conceptual level, how GA e-commerce tracking works. In this post I’ll get into the specifics of the code and how to install it.
This isn’t the most exciting stuff (that will be part 3), but a correct setup leads to correct data. :)
Step 1: Activate the Reports
The first step in setting up GA e-commerce tracking is enabling the e-commerce reports. Log into GA and edit the profile settings. Specify that your site is an e-commerce site. This activates the e-commerce reports.
There are other e-commerce settings that don’t get much use (unless you’re an international site). You can specify one of 25 different currencies (wow!) and the number of decimal places you would like displayed (1,2 or 3). Even if you use USD you can specify 3 decimal places. Go ahead and try it, it’s interesting.
Remember, e-commerce reports is a profile setting that is “off” by default. You’ll need to activate the reports for each new profile you create.
Step 2: Tag your Receipt Page
I know this seems like a silly step, but make sure you add the GA tracking code you your receipt page. You must have the standard GA tracking code on your receipt page in order to track transactions. The reason is that the e-commerce tracking code is stored in the ga.js. If this file is not included on the receipt page then you can’t track transactions.
Step 3: Install the Code
Let’s take a look at the code:
"order-id", // required
"affiliate or store name",
"order-id", // required
"unit price", // required
< /script >
_addTrans() method, creates the transaction and stores all the information about the transaction.
The second section, identified by the
_addItem() method, is used to add an item to the transaction. You need to create an
_addItem() section for each different item, or SKU, in the transaction. The order ID in the
_addItem() method must be the same order ID used in the
_addTrans() method. That’s how GA ties an item to a transactions.
The final section is the
_trackTrans() method. This method actually sends the data to GA by requesting the __utm.gif file once for the transaction and once for each item in the transaction. So if you have 3 different SKUs in a transaction there will be 4 requests fot the __utm.gif.
pageTracker object. If the
pageTracker object has not been created then you can’t call the e-commerce methods.
Just to reiterate a point: you must create server side code that outputs the transaction data in the format above. If you do not have access to your shopping cart code, and your cart provider does not provide e-commerce tracking, then you may be out of luck.
Once the code has been installed you should begin to see e-commerce data in your reports.
Notes and Suggestions
Like many things in Google Analytics, there are some things that can trip you up:
- If you do not wish to pass a certain piece of data to GA then do not add anything between the quotation marks. The only required fields are the order ID, the unit price of each item and the quantity of each item. Everything else is optional.
- Do not use currency identifiers or commas (to separate thousands) in any of the numeric fields (i.e. total, tax, shipping). These characters have caused problems in the past.
- Each piece of transaction data that you send to Google Analytics becomes a data element in GA, just like any other piece of data in GA (geo data, campaign data, browser data, etc.). You can do all sorts of neat things with filters and e-commerce data. More on this later.
- The affiliate or store name field is no longer used in the GA reports. However, the data is still collected by GA so you can use it in a filter.
- The transaction geographic data collected by GA is no longer used BUT it is collected. Google Analytics determines the location of the user, and thus their transaction, based on their IP address. The old version of the GA tracking code used the data specified in the transaction. Like the affiliate field, the data can be used in a filter.
In the next post I’m going to talk about some creative ways to use e-commerce tracking. Specifically, why I believe that everyone should use e-commerce tracking on their website.
This is part 1 in a multi-part series on e-commerce tracking: