Google Analytics Tutorial - Advanced e-commerce tracking
Another powerful feature of Google Analytics is the ability to track real e-commerce values to allow you to see the monetary value of different traffic sources and keywords, as well as providing a nice dashboard for tracking the profitability of your website.
Tracking e-commerce values
To track e-commerce values in Google Analytics you must first have set up Google Analytics as well as have set up conversion goals.
In the analytics settings for you site you should have ‘E-Commerce Website’ ticked as yes. This will give you a whole new dashboard and a new set of reports displaying relevent e-commerce data about your site.
Finally you must add some additional code to your checkout confirmation page, which will allow you to track the e-commerce data.
You must add an event handler to the body tag of the page:
<body onLoad="javascript:__utmSetTrans()">
And also the following code somewhere in the body of your document:
<form style="display:none;" name="utmform">
<textarea id="utmtrans">UTM:T|[order-id]|[affiliation]|
[total]|[tax]| [shipping]|[city]|[state]|[country] UTM:I|[order-id]|[sku/code]|[productname]|[category]|[price]|
[quantity] </textarea>
</form>
Anything in [ brackets ] should be replaced by actual variables passed to the page containing the relevent data.
There are two lines of data for use in e-commerce tracking. The line beginning UTM:T should be filled with variables containing data about the overall order and there should only be one of these lines per order. The line beginning UTM:I is for data about each individual product ordered and you should have as many of these as products were ordered (this can be achieved by looping over a data structure containing ordered products).
You will then have a lovely dashboard such as the one below:

Related Posts
- Google Analytics Tutorial - How to track conversion rates
- Google Analytics Tutorial - How to filter unwanted data in Google Analytics
- Google Analytics Tutorial - Setting up Google Analytics
- Understanding Web Analytics













July 17th, 2007 at 7:51 pm
So let me get this right…
If you’re URL variable is grandTotal (1shoppingcart), then you would replace [total]?
So it would be |grandTotal| not |[grandTotal]|
July 17th, 2007 at 8:00 pm
Hi Donovan,
Exactly right. The [] should be replaced by the actual variable.
So in some sites I’ve worked on the variable is something like $order_total so that would replace [total] surrounded by the ‘|’s in between all the different variables.
It might be like this:
UTM:T|$order_id|$affiliate|$order_total|$tax|
It’s also worth noting that you don’t need to use all the variables if you don’t want to measure all the metrics.
Hope that helps.
July 20th, 2007 at 9:58 pm
I just can’t get it to work! It’s not registering under Google Analytics that its a transaction… like nothing. Very frustrating. I’ve had a few successful transactions, but nothing reported a day or two later.
Any ideas?
D
July 21st, 2007 at 7:29 am
Have you got the normal Google Analytics tracking tag in the page as well? You need that too..
July 21st, 2007 at 8:07 am
Yeah i do! Nothing is working! Really freaky.
July 21st, 2007 at 8:07 am
I mean… google analytics works, and the goals, but just no ecommerce (yes, the box is ticked)
July 21st, 2007 at 10:48 am
If you want you could drop me an email and I’ll try and take a look at the page?
August 8th, 2007 at 12:07 am
Adam (any anyone else who can help),
I have tried to get Analytics to work with 1ShoppingCart and have even paid someone to do it. It still doesnt work. Here’s part of the problem: I mostly sell digital products. After a credit card is approved, the next page is where the customer can download the products. It is not a thank you page and it is not editable. 1SC will pass values to a thank you page. Customers only go to the thank you page if they click the “continue” button at the bottom of the download page. Most people dont click it because once they have their products downloaded they leave. I assume some people do click it, but the minority. I am looking for someone who can help me get Analytics to work with 1SC when selling digital products as I have described. I appreciate any help you can provide, including contact info for someone I can pay to get this working. Thanks!
August 17th, 2007 at 3:45 am
David,
What is the variable for 1shopping’s total_cost? I am helping a client setup a campaign selling books and I would like to use a variable that excludes shipping.
I have tried searching the 1shoppping cart website with no luck. Any help would be greatly appreciated.
Craig B
August 20th, 2007 at 11:47 pm
Hi David and Craig,
I’ve just got back from a holiday, I’ll try and take a look at your problems later this week when I get a chance (if you haven’t already solved them yourselves).
January 8th, 2008 at 6:18 pm
[…] You can still use Google Analytics just not very well. You have to leave it off the sales pages on 1shoppingcart meaning you can’t do any advanced e-commerce tracking. […]
February 28th, 2008 at 7:40 am
Hi folks,
I have had the same issue with the e-commerce tracking not getting processed to the google reports.
I have implemented the changes to the letter as per the google analytics e-commerce installation guide.
Please see my code below and let me know what could possibly be going wrong…:
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"));
var pageTracker = _gat._getTracker("UA-XXXXXX-X");
pageTracker._initData();
pageTracker._trackPageview();
pageTracker._addTrans(
"",
"",
"53.24",
"3.30",
"9.95",
"Burbank",
"CA",
"United States"
);
pageTracker._addItem(
"",
"41503 LARGE",
"Compression Short w/Protective Flex Cup",
"",
"39.99",
"1"
);
pageTracker._trackTrans();
March 1st, 2008 at 8:25 pm
Hello all,
I just wanted to update you folks that I was finally able to get the E-Commerce to start recieving data… It turns out you have to have something for the order id for it to work. So in order to make up some relatively unique number given we do not have order-id’s I used the Javascript UTC method on the current date.
Long story short if it does not work for you, just ensure you have data for all of the variables and it should work properly for you.
Cheers!
March 3rd, 2008 at 2:51 am
Hi Guys,
I’ve been trying to integrate GA E-commerce tracking with Paypal for a few weeks now. There doesn’t seem to be a lot of info out there on the subject.
After a few weeks and a few hundred dollars, I’ve come up with a script that fully integrates Paypal with GA E-commerce. I’ve wrote a free ebook that includes the script you’ll need at no cost.
There is nothing for sell here. I just wanted to see this info more widely available.
You can get the ebook from this link.
http://www.brentcrouch.com/2008/03/02/google-analytics-e-commerce-tracking-using-paypal-pdt/
Good Luck,
Brent Crouch
March 19th, 2008 at 9:47 am
Thanks for the tutorial Adam it works perfect for me.
Regards
April 3rd, 2008 at 2:43 pm
Good tutorial, now I can use this for some clients.