Magento Google Analytics Goal Funnel

Here are the steps to create a goal funnel in Google Analytics for Magento.

Step 1: Goal Set-up

Login to your Google Analytics account. Click on Goals and then New Goal.

Step 2: Goal Description

In the Name field, enter the title for your goal, such as “Completed Purchases.” Select Destination for the Type and click “Next Step”.

Google-Analytics-Goal-Description

Step 3: Goal Details

For Destination, select Regular expression. Enter /success in the field. Leave Value set to Off. Set Funnel to On. Click Add Another Step so that you have eight lines for entering funnel steps.

The following are what you should enter for each step. The first is the Name (you can use whatever names you prefer; these are the ones we use), and the second is the value for the Screen/Page field:

Checkout – /checkout/onepage/
Billing Info – /checkout/onepage/opc-billing/
Shipping Info – /checkout/onepage/opc-shipping/
Shipping Method – /checkout/onepage/opc-shipping_method
Payment Info – /checkout/onepage/opc-payment
Order Review – /checkout/onepage/opc-review
Order Clicked – /checkout/onepage/opc-review-placeOrderClicked

Analytics-Goal-Funnel

Step 4: Modify onepage checkout template file

Modify the file called onepage.phtml located inside checkout/onepage.phtml within your theme’s template directory, if the file doesn’t exist here copy it across from the base/default folder:

Your Theme:
app/design/frontend/[package]/[yourtemplate]/template/checkout/onepage.phtml
Base Default:
app/design/frontend/base/default/template/checkout/onepage.phtml

Once you’ve got the file open paste in the following code at the end of the file, save and upload.

<script type="text/javascript">
  Checkout.prototype.gotoSection = Checkout.prototype.gotoSection.wrap(function(parentMethod, section, reloadProgressBlock) {

    // Call parent method.
    parentMethod(section, reloadProgressBlock);

    var _gaq = _gaq || [];

    try {
      // push current checkout section to google analytics if available.
      _gaq.push(['_trackPageview', '<?php echo $this->getUrl('checkout/onepage'); ?>' + section + '/']);
    } catch(err) {
      // silent fail.
    }
  });
</script>

Say Hello! Don’t be shy.