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:

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, | 12

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

The amount of checkout steps doesn’t matter! Toni Anicic
, | 1

The amount of checkout steps doesn’t matter!


  1. Guilherme,
    – change success URL to “head match”
    – check slashes – “/” in your rules and HTTP request for __utm.gif.

    For more troubleshooting:

    Do you have any success goals in your GA by now?!

    If you do, then check Conversions -> Goals -> Reverse goal path – that’s the actual conversion path, you can use those URLs in GOALS definition.

    How do those paths look like (URL structure)?

  2. Thanks for your code 🙂
    but this line is missing in your Code:


  3. @Vadim, and @all having issues – when submitting issues, please refer to debugging steps [4] in the article, and submit:
    1] info about checkout page
    2] HTTP requests output(s) – just like in the example [section 4 in the article]

  4. Excellent article; followed the simple (and well documented steps) … working like a charm! Thanks 🙂

  5. Hi, thanks for the article.
    We have followed all the steps, but we cannot get the desired results. After /checkout/onepage/ step, GA displays transitions to the Billing sections as people drop-offs and the URL for people dropoffs is /checkout/onepage/billing/. We use custom Magento theme but it has one-page checkout. Here is the screenshot

    . We have modified both default onepage.phtml for default and our themes, but nothing has changed. Are there any reasons for issue persistence? Please, advise. Many thanks.
    P.S. We have tried different variants of script code (available above) but nothing.

  6. @Toni

    Thanks for the help – but i dont have such parameters

    Is there any other way to activate the funnel?

  7. @Andreas,

    Exact match method will not work if something sends some parameters in your URLs during the checkout. Do you have some parameters such as ?ref generated by some testing, analytics or affiliate services or extensions?

  8. Hello,

    same Problem like @adam:

    Funnel works, but i have also 100% checkouts (That would be nice but i can imagine).

  9. Hey Drazen, I’ve tried your guide, but it doesn’t work.
    instead of getting the section in the end og the URL, I get:
    checkout/onepage/?___SID=U Do you know why this happens? it is
    magento ver. 1,702.

  10. Hey Drazen, can you pm me? Then we can post the resolution in comments?

    I’d appreciate the help.

    Further findings / notes:
    * guest checkout is not enabled
    * _utm for billing never gets sent
    ** if you are already logged in it takes you right to this step, so it never pushes this step to GA

  11. Hi Adam,

    Could you post a acreenshot to your funnel?

    Could you post test results? Go to checkout and watch all HTTP requests for _utm.gif -> post a link to screenshot. Tnx…

    “Required step” is not necessary, actually, it should be left unchecked as users might jump right into one of the steps (actually, for most configurations it’s /checkout/onepage/, but anyway, leave it unchecked).

  12. I’m surprised that the “head match” doesn’t skew results with these urls

    I’m try to track down why our analytics reports 100% conversion at each step.

    I noticed also that the checkbox “required step” isn’t checked in your example either.

    1. Hey Adam – did you ever figure out why the later steps always show 100% conversion? I can’t seem to find a solution.

    2. Hi,

      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?

  13. Hi Drazen Karacic

    Have you had a chance to think about my idea of abandoned steps report?

    That would be one of the most important Magento extensions!

  14. @Si
    I had the same issue. I just replaced

    _gaq.push(['_trackPageview', '<?php echo $this->getUrl('checkout/onepage'); ?>' + section + '/']);


    _gaq.push(['_trackPageview', '/checkout/onepage/' + section + '/']);
  15. hi drazen,

    i am looking for magento shopping cart abandonment rate decreasing methods,and your article definitely helped me with tracking abandonment rate.

    i have never thought of using GA to track, alternatively,i used third party service to track and analyse for me.

  16. @Drazen Karacic

    You got it 100% right – this exactly what I had in mind: report which would show customers who abandoned checkout and showing at which step it happened.

    If implemented as Magento plugin it might also have an option to retrieve that abandoned shopping cart so owner can make an adjustments and make an counter offer to client. – Let say I see that customer dropped at shipping cost, we check shipping quote and see that we can offer cheaper option so we make an offer which customer can accept. (but that may be too much to ask :))

  17. Hi Drazen

    Any thoughts on what might be causing my ‘/’ issue as this is negating what could otherwise be extremely useful info…

    Cheers, Si

  18. Hi Vincent,

    Tnx for your comment. We have discussed internally about this nice idea you have.

    It could be done with two different approaches, depending on your particular needs.

    Could you specify your requirement a little more? Would you like to have some kind of report from where you would see a list of users that abandoned checkout at #1, #2, #3, and then have possibility to contact them with some message? Is that what you had in mind?

  19. Nice article.What would be nice to know is which customer dropped at which step so owner could follow up with customer. I guess it could be done – since after step one in the checkout we know customer’s information (name, email) it should be possible to track how far did he(she) go in the checkout process.

    Does anybody know solution for this – existing magento plugin probably?

  20. Excellent article as always, thanks guys. Just one question, have had this implemented for a couple of weeks now and am getting data through, but there seems to be a problem. When I look at the funnel it shows that most of my customers are exiting at the Checkout Intro stage, but the exit address is strange – its the entire url prefixed with a forward slash – i.e. ‘/’. Any ideas what might be causing this?

  21. no setting required for this in magento google have default functionality i am running it without it google setting because google analytics have default functionality to track ajax pages

  22. @Rose, you’be busted us!

    Yes, I’m Dr. Ray’s twin bro, but what you didn’t notice is that Tomislav is Scott Wolf . We’ve met in Hollywood during his medical consultation he was having with my brother.

    We talked about technology and e-commerce, and the rest is history…

  23. Hi Rick,

    It depends on how you implemented GA tracking on your site, and what’s your “Default URL”.

    You are most likely the owner of domain and all subdirectories, and you probably track all of the traffic.

    In that case the goal would be relative to your domain’s root: store/checkout/onepage/success

    But, if you’ve implemented GA to track only traffic in specific subdirectory (i.e. Default URL is “”), the goal would be checkout/onepage/success

    P.S. Sorry for delay, vacation time 😉

  24. Hi Peter, I’m glad you liked it. 🙂

    By default theme, I meant all themes that handle Onepage checkout functionality (prototype accordion on Onepage checkout, to be more specific) as default theme.

    For all other situations, script should be tweaked to fit the general principle of invoking a fake pageview GA call (as in this case) or event tracking in GA.

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.