Tracking Onepage Checkout abandonment using Google Analytics

Tracking Onepage Checkout abandonment using Google Analytics

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

You made it all the way down here so you must have enjoyed this post! You may also like:

How to connect Google Analytics 4 to Magento 2 Bojan Mareljic
Bojan Mareljic, | 35

How to connect Google Analytics 4 to Magento 2

Meet Magento Belarus features an Inchooer talking Magento 2 Checkout Ivona Namjesnik
Ivona Namjesnik, | 0

Meet Magento Belarus features an Inchooer talking Magento 2 Checkout

Tracking Magento “add product to cart” action for analytic software purpose Branko Ajzele
Branko Ajzele, | 13

Tracking Magento “add product to cart” action for analytic software purpose


  1. Since some new comments are buried in comment threads, this a comment repost for a frequent question – 100% match:

    100% conversion is due to step matching. If your steps are i.e.

    It would have 100% conversion rate due to how GA matches steps [weird, I know :)]. More info:

    Solution [for this example]: change first step to use regex that would match only that particular URL: “/checkout/(onepage/index/$|onepage/$)$”

    Do you have similar situation?

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

    1. Hi Bar,

      can you check/post you funnel steps report [screenshot would be best]?

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

  4. 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?! 😉

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

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

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

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

Tell us about your project

Drop us a line. We'd love to know more about your project.