Google Analytics E-Commerce Tracking Pt. 1: How It Works

This post is the first in a series of e-commerce transaction tracking with Google Analytics. Why is e-commerce tracking important? Well, transaction data is a vital piece of information when analyzing online business performance.

Sure, it’s great to measure things like conversion rate, but revenue is much more tangible to many business owners. Having the e-commerce data in your web analytics application makes it easier to perform analysis. Do you need to set up e-commerce tracking? No, but it sure helps. :)

The Big Pictures

E-commerce tracking is based on the same principal as standard pageview tracking. JavaScript code sends the data to a Google Analytic servers by requesting an invisible gif file. The big difference is that e-commerce data is sent rather than pageview data.

But how does Google Analytics get the e-commerce data? That’s the tricky part. You, the site owner, must create some type of code that inserts the transaction data into the GA JavaScript. Sounds tricky, huh? Well, its not that bad.

Step by Step: How it Works

Let’s break it down and walk through what actually happens.

1. The visitor submits their transaction to your server.

2. Your server receives the transaction data and processes the transaction. This may include a number of steps at the server level, such as sending a confirmation email, checking a credit card number, etc.

3. After processing the transaction the server prepares to send the receipt page back to the visitor. While preparing the receipt page your server must extract some the transaction data and insert it into the Google Analytics JavaScript. This is the code that you must create.

4. The receipt page is sent to the visitor’s browser.

5. While the receipt page renders in the visitor’s browser the e-commerce data is sent to Google Analytics via special GA JavaScript.

Here’s a basic diagram of the process. Again, the biggest challenge during implementation is adding code to your web server that inserts the transaction data, in the appropriate format, into the receipt page. I’ll cover the setup in part 2 of this series.

What Data can be Tracked?

Google Analytics collect two types of e-commerce data: transaction data and item data. Transaction data describes the overall transaction (transaction ID, total sale, tax, shipping, etc.) while item data describes the items purchased in the transaction (sku, description, category, etc.). All of this data eventually ends up in GA reports. Here’s a complete list of the data:

Transaction Data

  • Transaction ID: your internal transaction ID [required]
  • Affiliate or store name
  • Total
  • Tax
  • Shipping
  • City
  • State or region
  • Country

Item Data

  • Transaction ID: same as in transaction data [required]
  • SKU
  • Product name
  • Product category or product variation
  • Unit price [required]
  • Quantity [required]

A few notes about the data. First, the geo-location data is no longer used by Google Analytics. The new version of GA tries to identify where the buyer is located using an IP address lookup.

Also, you should avoid using any non-alpha numeric characters in the data. Especially in the numeric fields. Do not add a currency identifier (i.e. dollar sign) in the total, tax or shipping fields. this can cause problems with the data.

Like this post? Check out the rest of the series:

Google Analytics E-Commerce Tracking Pt. 2: Installation & Setup
Google Analytics E-Commerce Tracking Pt. 3: Why EVERYONE Should Use It
Google Analytics E-Commerce Tracking Pt. 4: Tacking Lead Gen Forms

Be Sociable, Share!

    Like this post? Sign up to get posts delivered to your inbox.


    1. Craig Broadman says

      When will part 2 be published, I am very intreaged as I have tried to get google-analytics ecommerce working for my website using a custom control and it doesn’t seem to work at the moment


    2. Aaron says

      I very much appreciate your blog but there is a burning question I have seen no answer to:
      – we would like to track who is clicking on our email tag-lines that have our corporate website URL in them.
      – I have tried making the link and then I have a virtual directory in IIS redirect to
      – The problem is that I cannot figure out how to make GA show me how many hits to came from
      – Is there a simple process I am missing?

      Thanks for the help

    3. says

      Hi Aaron,

      You’re looking for information on Link tagging. Check out this post I wrote about link tagging.

      You may also want to check out this post re: offline campaign tracking. It uses the exact virtual URL technique you describe.

      Thanks for reading and thanks for the question.


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

      Good Luck,

      Brent Crouch

    5. says


      E-commerce tracking is fine. BUT in my opinion i think google already knows to much about us and companies. The know our adwords spendings, our traffic and giving them our total e-commerce income to them is a point that goes to far. The Analytics figures are in fact not even correct so it will never give the correct status.

      Companies that run millions in e-commerce will not give google those benchmarking benefits for their own commercial purposes if you ask me. Like our company. We use besides Analytics Urchin for servers. That is not free of course but has the same benefits.

      Small companies can easy work with Analytics and E-commerce tracking if you ask me.

    6. says

      i understand the code and what its doing and where to put it but my question is..the application I’m using is Flex and i don’t have a URL to a receipt page or a thank you page. So if someone can shead some light on this for me that would be great.


    7. says

      Hi Elizabeth,

      You need to somehow embed the code in your Flex. Talk to your Flex developer and ask them to add the code to the “receipt page” inside of the Flex code.

      Hope that helps,


    8. says

      “Insert transaction data into GA JS” – so we basically add this to the JS itself or pass it to a JS?

      – I am wondering how we do it for an initial spend? AND,
      – I am wondering how to do it for subsequent spending?

      Justin – great article, it would be great to work on some case studies or hypothetical examples to help certain business types achieve their goals. I could certainly create one for my business model and help the community who use GA.


    9. says

      Hi btard,

      Thanks for the comment. To answer your specific questions:

      – I am wondering how we do it for an initial spend? AND,

      Your server level code needs to take the transaction data and format such that Google Analytics can process it. GA can only record the data if you format in the special GA format, which I list above.

      – I am wondering how to do it for subsequent spending?

      You need to change your server code so that it will automatically format the data every time a transaction is submitted. This is the most difficult part of ecommerce tracking. Writing the server code takes time and can be pretty involved based on how elaborate your ecommerce platform is.

      Hope that helps and thanks again for the question.


    10. says

      Great post as usual, the e-commerce tracking is a useful asset. I’m wondering whether it’s suitable for my scenario. I have pages which are worth more than others, but this depends on the advertising campaigns that are running at the time.

      Currently we’re trying goals but quickly realised that 1 visitor can’t trigger multiple goals, so this won’t give us an accurate figure if someone browses, 4 “premium” pages, we’ll only get 1 goal.

      Using e-commerce tracking, we could get the ad publishing system to write a value out to the GA tag, which will indicate the value of that ad impression, however this wouldn’t have a transaction ID which i believe to be required…

      do you have any suggestions in this scenario?

    11. says

      Hey Chris,

      It does sound like ecommerce tracking will be more appropriate for you. As for the transaction ID, you can create your own value using something unique, perhaps a random number in combination with a time stamp. The big question is, do you want to ‘group’ multiple transactions together for a single user? If so, you can use the same transaction ID for all transactions that a user submits.

      Hope that puts you on the right track.


    12. says

      Thanks Justin great post,

      Great pointers, now I have to set up better method for e-commerce tracking. I didn’t know that the new version of GA tries to identify where the buyer is located using an IP address lookup.

    13. says

      Thanks for this post. I set up ecommerce tracking a while back but am looking to refresh myself on it. Read quite a few articles but this is very good. Will be checking out the other parts soon. Thanks :)


    1. […] Google Analytics has quickly become one of the most popular analytics software available, additionally there are numerous resources available which deal with configuration, implementation, analysis, and reporting. Below I have compiled some of the most useful resources for Google Analytics related strategies.EpikOne: Improving the quality of your report’s data EpikOne: Google Analytics E-Commerce Tracking Pt. 1: How It WorksEpikOne: Google Analytics E-Commerce Tracking Pt. 2: Installation & SetupROI Revolution: Google Analytics ROI Calculation MacroROI Revolution: Should You Join the Migration? urchin.js Migrates to ga.jsROI Revolution: Tracking Secondary Sources and Autoresponders Using Site SearchGoogle Analytics Blog: Where Did My Paid Search Traffic Go?Google Analytics Blog: Site Search Now AvailableYouTube – Alex Ortiz: Advanced Techniques in Google Analytics YouTube – Avinash Kaushik: Google Analytics -Context and actionability in web analytics YouTube – Nick Mahailovski: Tracking Offline to Online Campaigns YouTube – Google Analytics Interface Tutorial […]

    2. […] Sitet Analytics Talk har skrevet 4 gode artikler omkring opsætningen og kreativ brug af E-commerce i Google Analytics. addthis_url = ‘'; addthis_title = ‘E-commerce+med+Google+Analytics'; addthis_pub = ‘tabasco'; […]

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>