About Adam Taylor...

I am a student, blogger, lazy entrepreneur....


I write about: Analytics, blogging, search engine optimisation and social media marketing.


Find out more...

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:

Google Analytics e-commerce dashboard

Related Posts


Subscribe to the Conversion Matters feed!

16 Responses to “Google Analytics Tutorial - Advanced e-commerce tracking”

  1. Donovan Says:

    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]|

  2. Adam Says:

    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.

  3. Donovan Says:

    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

  4. Adam Says:

    Have you got the normal Google Analytics tracking tag in the page as well? You need that too..

  5. Donovan Says:

    Yeah i do! Nothing is working! Really freaky.

  6. Donovan Says:

    I mean… google analytics works, and the goals, but just no ecommerce (yes, the box is ticked)

  7. Adam Says:

    If you want you could drop me an email and I’ll try and take a look at the page?

  8. David Says:

    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!

  9. Craig B Says:

    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

  10. Adam Says:

    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).

  11. Adding Google Analytics tracking to 1shoppingcart » Adam Taylor - Conversion Matters Says:

    […] 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. […]

  12. Robin Says:

    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();

  13. Robin Says:

    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!

  14. Brent Crouch Says:

    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

  15. Janni Says:

    Thanks for the tutorial Adam it works perfect for me.
    Regards

  16. Ryota Masaki Says:

    Good tutorial, now I can use this for some clients.

Leave a Reply

Subscribe to Comments?

Tamar Goes To Town 121 Tamar Goes To Town 120 Tamar Goes To Town 119 Tamar Goes To Town 118 Tamar Goes To Town 117 Tamar Goes To Town 116 Tamar Goes To Town 115 Tamar Goes To Town 114 Tamar Goes To Town 113