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

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

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

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

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

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

70 comments

  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.
    /checkout/onepage/
    /checkout/onepage/two/
    /checkout/onepage/three/

    It would have 100% conversion rate due to how GA matches steps [weird, I know :)]. More info: https://support.google.com/analytics/answer/2976313?hl=en

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

    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?

    Thanks

    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.

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

  10. Mathias, yes, we noticed, but took some to update the article. Tnx for your comment, it’s fixed now.

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

    this.reloadProgressBlock(section);

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

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

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

  15. @Toni

    Thanks for the help – but i dont have such parameters

    Is there any other way to activate the funnel?

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

  17. Hello,

    same Problem like @adam:

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

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

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

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

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

    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.
      /checkout/onepage/
      /checkout/onepage/two/
      /checkout/onepage/three/

      It would have 100% conversion rate due to how GA matches steps [weird, I know :)]. More info: https://support.google.com/analytics/answer/2976313?hl=en

      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?

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

  23. @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 + '/']);
  24. 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.

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

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

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

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

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

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

  31. Hi nicki,

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

    Tnx

  32. @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…

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

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