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

app/design/frontend/base/default/template/checkout/onepage.phtml

and paste this code at the end of file:

<script type="text/javascript">
Checkout.prototype.gotoSection = function(section) {
try {
_gaq.push(['_trackPageview', '<?php echo $this->getUrl('checkout/onepage'); ?>' + section + '/']);
} catch(err) { }
section = $('opc-'+section);
section.addClassName('allow');
this.accordion.openSection(section);
};
</script>

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

45
Top

Enjoyed this post?

Subscribe to our RSS Feed, Follow us on Twitter and spread it to your friends!

Author

Drazen Karacic

eCommerce Consultant

Cacan is an eCommerce Consultant at Inchoo. He worked in banking sector for almost 10 years before he joined us. After first 2 months working as marketing manager, he moved to Manaus team where he is having a role of project manager.Starting this summer, he is a member of ICG together with Toni Anicic.

Other posts from this author

Discussion 45 Comments

Add Comment
  1. Hi, I love this article but what about a non-default Magento theme. Can you explain me a little bit what to do?

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

  3. I have a store located at http://www.queencreekolivemill.com/store/

    When I am setting up the funnel analytic’s for the one page checkout, do i do it like this:

    /checkout/cart/
    or like this
    /store//checkout/cart/

    also, would the goal URL be:
    /checkout/onepage/success
    or
    store//checkout/onepage/success

    Thanks – Rick

  4. Uncaught ReferenceError: Checkout is not defined

  5. 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 “wwww.domain.com/store”), the goal would be checkout/onepage/success

    P.S. Sorry for delay, vacation time ;-)

  6. 54dev,

    Can you please provide URL where error can be reproduced?

    Tnx…

  7. i used gomage onstepcheckout

  8. Hi 54dev,

    This tutorial is for Magento’s default Onepage checkout, but this technique could be applied to other checkouts as well.

    Of course, it doesn’t make too much sense in applying this technique in oneSTEP checkout of any kind. ;-)

    If you would like to track user activity in oneSTEP checkout, this would be a good starting point:
    https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide

  9. ok,thank you very much!:)

  10. Rose

    greetings.
    are you the clone of the DR. Ray?
    You are very equal

  11. This one? http://bit.ly/AiHbdA
    I heard that Drazen is his evil twin brother who stole his money and moved to Croatia.

  12. @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 http://bit.ly/QbgQts . 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…

  13. nicki

    its not like this , you made it complicated

  14. Hi nicki,

    Tnx for your input, could you please elaborate your statement, and give us easier way.

    Tnx

  15. nicki

    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

  16. @nicki, care to explain a bit further? Are you talking about GA events tracking?

  17. Si

    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. ‘/https://cheshirepineandoak.com/checkout/onepage/billing/’. Any ideas what might be causing this?

  18. 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?

  19. 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?

  20. Si

    Hi Drazen

    Any thoughts on what might be causing my ‘/https://cheshirepineandoak.com/checkout/onepage/billing/’ issue as this is negating what could otherwise be extremely useful info…

    Cheers, Si

  21. @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 :) )

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

  23. Hi “non woven”, :)

    Tnx for your comment, I’m glad it helped.

    Take a look at Srdjan’s article in the series of GA tracking in Magento:

    http://inchoo.net/ecommerce/magento/track-validation-errors-on-magento-forms-using-google-analytics/

    It might help in other situations, as well…

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

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

    with

    _gaq.push(['_trackPageview', '/checkout/onepage/' + section + '/']);
  25. Si

    @Luis

    Cheers for that. Have made the change and uploaded. Will see what happens.

  26. @Luis
    You beat me to it, I was just testing the same change before posting the answer. Works for me!

  27. Does this work for Magento Go?

  28. Vincent

    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!

  29. @Vincent:
    See if you can find a way to drop shipping fees entirely. Shipping fees seem to have quite an impact on conversions, even when they are low.

    Source: http://www.fairgroundmedia.com/improve-conversion-rates-with-shipping-options-infographic

  30. adam

    I’m surprised that the “head match” doesn’t skew results with these urls
    /checkout/onepage/
    /checkout/onepage/billing/
    /checkout/onepage/shipping/
    /checkout/onepage/shipping_method/
    /checkout/onepage/payment/
    /checkout/onepage/review/

    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.

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

  32. adam

    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

  33. Hi Adam,

    Do you have “required step” checkbox checked (switched on)?

  34. RL

    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.

  35. Andreas

    Hello,

    same Problem like @adam:

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

  36. @Andreas,

    Just set it to exact match.

  37. Thanks @Toni ! I will try that.

  38. +1 for Toni’s advice. I wasted days on this – the only way I could get it to work is “exact match”

  39. Andreas

    @tone

    this does not work. i have more goals reached than people in the funnel

  40. Andreas

    Appendix: with “exact Match” i have less funnel Users than User at the Goal

  41. @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?

  42. Andreas

    @Toni

    Thanks for the help – but i dont have such parameters

    Is there any other way to activate the funnel?

  43. Vadim

    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

    http://screencast.com/t/yZ5oFWfO3

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

  44. Riskywebmaster

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

  45. @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]

Add Your Comment

Please wrap all source codes with [code][/code] tags.
Top