Report each step of Magento's One Page Checkout to Google Analytics


/ Published in: PHP
Save to your folder(s)

This code allows you to track each step of Magento's One Page Checkout in Google Analytics. I installed it at the bottom of my `checkout/onepage.phtml` template file. Once installed, you can set up a funnel for the following:

* `/checkout/onepage/`
* `/checkout/onepage/billing/`
* `/checkout/onepage/shipping/`
* `/checkout/onepage/shipping_method/`
* `/checkout/onepage/payment/`
* `/checkout/onepage/review/`
* `/checkout/onepage/success/`

(This is a tweak of code [seen here](http://www.magentocommerce.com/boards/viewthread/12564/P0/). I prefer the gist of lanthaler's method over FOOMAN's because the data sent to Google is more specific, and based on explicit requests to load sections rather than requests to save data.)


Copy this code and paste it in your HTML
  1. <script type="text/javascript">
  2. // Report each step of the checkout process to Google Analytics
  3. Checkout.prototype.gotoSection = function(section) {
  4. try {
  5. pageTracker._trackPageview('<?php echo $this->getUrl('checkout/onepage') ?>' + section + '/');
  6. } catch(err) { }
  7.  
  8. section = $('opc-'+section);
  9. section.addClassName('allow');
  10. this.accordion.openSection(section);
  11. };
  12. </script>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.