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 – Setting up Google Analytics
- Adding Google Analytics tracking to 1shoppingcart
- Google Analytics Tutorial – How to track conversion rates
- Google Analytics Tutorial – How to filter unwanted data in Google Analytics
- Was there a reason for the recent Google Analytics downtime?
Bookmarking
-
Stumble | Digg | del.icio.us | RSS


{ 1 trackback }
{ 18 comments… read them below or add one }
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]|
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.
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
Have you got the normal Google Analytics tracking tag in the page as well? You need that too..
Yeah i do! Nothing is working! Really freaky.
I mean… google analytics works, and the goals, but just no ecommerce (yes, the box is ticked)
If you want you could drop me an email and I’ll try and take a look at the page?
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!
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
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).
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();
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!
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
Thanks for the tutorial Adam it works perfect for me.
Regards
Good tutorial, now I can use this for some clients.
Hi,
I’ve put e-commerce GA tracking code on my customer’s website, but I’m not getting any data. From the source code it seems the e-commerce is working perfectly, but it’s not generating any data. I tried all possible permutation & combination.
I’m placing my GA e-commerce code at the end of this mail. Can you please help me.
Thanks
Arijit
pageTracker._addTrans(700137282,FNP,
678,1,1,Mumbai,Maharashtra,India);
pageTracker._addItem(700137282,HFN2,Holi Sentiments,1180,319,1);
pageTracker._addItem(700137282,HFN1,Holi Wishes,1180,359,1);
pageTracker._trackTrans();
Thanks for this! Its really helped me on a new venture I am working on as the previous average solution wasnt working.
-> How to display category vice products in asp.net application from 1shoppingcart website. (API of list of products)?
-> How to get credit card information on thank you page?
-> How to pass custom variables on view cart page?
I really appreciate your help.
Thank You.