Posted By

jdbartlett on 10/01/09


Tagged

magento


Versions (?)

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


 / Published in: PHP
 

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

  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
Posted By: contactmaan on October 13, 2009

Hi, I have just added the script to the checkout/onepage.phtml page. Please tell what match type (Head, Exact or Regular Expression) should I select?

You need to login to post a comment.