Tracking Onepage Checkout abandonment using Google Analytics

Photo: Holger Prothman

In the process of conversion rate optimization  a store owner will sooner or later hit a wall with available Magento tools. While e-commerce tracking and cart abandonment information work great with Magento, checkout process is still a bit foggy area.

That’s where tracking checkout process and knowing the right moment/step of checkout abandonment using Google Anaytics comes in hand…

For this one we will use native Google Anlytics trackPageview method. Please note, this one works only with  default Magento’s onepage checkout.

[1.] If it’s not enabled, enable Google Analytics  from Magento admin.

[2.] Edit onepage.phtml in your Magento theme directory [this is location for default theme]:


and paste this code at the end of file:
code updated: 21.08.2013. [tnx Matej ;-)]

<script type="text/javascript">
 Checkout.prototype.gotoSection = function (section, reloadProgressBlock) {
 if (reloadProgressBlock) {
// Checkout abandonment rate - by Inchoo
 try {
 _gaq.push(['_trackPageview', '/checkout/onepage/' + section + '/']);
 } catch (err) {
this.currentStep = section;
 var sectionElement = $('opc-' + section);
 this.accordion.openSection('opc-' + section);
 if (!reloadProgressBlock) {

[3.] create Goal with funnel inside Google Analytics

Define all funnel steps as described above:

Google Analytics funnel steps:

  • /checkout/cart/
  • /checkout/onepage/
  • /checkout/onepage/billing/
  • /checkout/onepage/shipping/
  • /checkout/onepage/shipping_method/
  • /checkout/onepage/payment/
  • /checkout/onepage/review/

[4.] Test your new settings

Go to your Magento onepage checkout and watch for HTTP requests sent after each step/accordion is finished. If there is an  HTTP request for __utm.gif  after every checkout/accordion with appropriate parameters and their values (underlined) – then your data is being collected.

Wait for a few hours, days or weeks, and then check your Google Analytics under:

Conversions -> Goals -> Funnel Visualization 

and select appropriate goal/funnel.

While this method will not give you a definite answer to why people are abandoning eventual purchase, it might give you a better clue on what part of checkout process needs more of your attention, whether it’s overall checkout user experience (more information for each of the steps, etc.) or specific checkout options (shipping rates, available payment/shipping methods, etc).

If you need any help, we can do a Magento Website Assessment for your site.

About Drazen Karacic-Soljic

eCommerce Consultant

Cacan is an eCommerce Consultant at Inchoo, where he's monitoring key performance indicators of client's online store and suggesting improvements.

Read more posts by Drazen / Visit Drazen's profile


  1. After following this tutorial, we are seeing some activity on our funnel visualization, however I do not believe it is reporting accurately. According to our funnel, of the visitors that proceed to the Billing step, it is reported that 100% of them complete the funnel by placing an order. Obviously this is incorrect.

    Is anyone experiencing similar behavior? Any advice or help would be greatly appreciated.

    We are using Magento EE

  2. When adding the suggested JavaScript, it has broken my CheckOut Progress. This is not refreshed anymore ( with Ajax ), but is only showing headers ( Billing Address, Shipping Address and Payment ) from the steps.

    We removed shipping-fee from onepage checkout.

  3. You say “Please note, this one works only with default Magento’s onepage checkout.”

    We are using a different onepage checkout extension. Is it possible to set something similar to track the performance of that page?


    1. Hi Maria,

      yes, it’s possible to track performance of other “onepage” checkout solutions, but it would require analysis and custom dev for each of them. As a rule of a thumb – if there is a linear flow between checkout steps of any kind – it would be possible to track performance for each step and create a funnel. Please, contact us if you’d like us to take a look…

      I put note about default Magento onepage checkout mostly due to fact that there are many different implementations of “onepage” and “onestep” checkouts used with Magento out there. I must say, although it is possible to track individual user actions/steps for “onestep” checkouts, I still haven’t seen use case that resulted in any meaningful report mostly due to non-linear nature of “onestep” checkout. I’d like to see a case where analytics funnel works in “onestep” checkout environment. Anyone?! 😉

  4. After much tinkering, I found a solution that seems to be working. Here are the steps that I took:

    1. Created a filter, type Custom filter, Search and Replace. Filter field “Request URI”, Search String “/checkout/onepage/index/”, Replace String “/checkout/onepage/”, Case sensitive: No

    2. On the goal. Made sure that the destination was set to “Regular Expression” and set the second step, “Checkout” to “/\/checkout\/onepage\/$/”

    That seems to do the trick. But give it a little time to propagate.

  5. Thanks for this tutorial. Big Help! It is working for me and reporting in analytics, but I have noticed that now after adding the script to the bottom of the onepage.phtml the checkout progress on the right column is not functioning as it should. Any ideas on how I can correct this? I will be removing the script from our main site until I can get this functioning in our dev environment. any help would be much appreciated.

  6. Another great tutorial by Inchoo 🙂 I wondered if anyone has managed to track the contact form enquiries as an analytics goal? Thanks!

  7. Drazen
    All slashes are right and I changed the success URL to “head match”. I’ll monitor these Goal!

    Looking my “Checkout Success” reverse goal path I saw the steps: review, payment, shipping_method, etc., like you did in this tutorial

    Thanks for the help.

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=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.