Magento Google Analytics Funnel for Tracking Each Step of One Page Checkout
Magento Google Analytics - I have spent the entire afternoon working on a client’s Magento website. As an update to my previous post “Magento One Page Checkout vs. Multipage Checkout“, I needed to set up a Google Analytics funnel to accurately track each step of the One Page Checkout process. Because it obviously only uses one page and AJAX, the default Google Analytics configuration is not able to track each of the six steps of the checkout process to determine where the visitors are abandoning their transactions. Clearly, it is very valuable to have that information available. Luckily for us, we are able to do just that. Here are the steps:
1. Open up the template file /app/design/frontend/default/YOURTEMPLATENAME/template/checkout/onepage.phtml in a text editor or WYSIWYG web editor such as Dreamweaver.
2. Paste the following code to the very bottom of the onepage.phtml file (You may have to replace the quotes in plaintext for it to work, fyi):
<script type=”text/javascript”>
Checkout.prototype.gotoSection = function(section) {
try {
pageTracker._trackPageview(’<?php echo $this->getUrl(’checkout/onepage’) ?>’ + section + ‘/’);
} catch(err) { }
section = $(’opc-’+section);
section.addClassName(’allow’);
this.accordion.openSection(section);
};
</script>
3. Save and upload the template file and you are done with the hard part and you will now be able to track the views of each of the six steps!
4. Now if you want to set up the Google Analytics conversion tracking and funnel to determine where the users are dropping off, you can do so by creating a new Goal in Google Analytics and by using the following settings:
Goal Type: URL Destination
Match Type: Head Match
Goal URL: /checkout/onepage/success/
Funnel Steps:
Step 1: /checkout/onepage/
Step 2: /checkout/onepage/billing/
Step 3: /checkout/onepage/shipping/
Step 4: /checkout/onepage/shipping_method/
Step 5: /checkout/onepage/payment/
Step 6: /checkout/onepage/review/
And that’s it!