Skip to content

Instantly share code, notes, and snippets.

@ifnull
Created November 15, 2014 01:02
Show Gist options
  • Save ifnull/dae7ae8fbfde4890591c to your computer and use it in GitHub Desktop.
Save ifnull/dae7ae8fbfde4890591c to your computer and use it in GitHub Desktop.
Add Magneto cart abandonment funnel to Google Analytics

Magento Code

Add the following code to checkout/onepage.phtml at the bottom.

By default this file is located here:

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

In a custom theme is would be somthing like:

app/design/frontend/default/shopper/template/checkout/onepage.phtml
//<![CDATA[
Checkout.prototype.gotoSection = function(section, reloadProgressBlock) {
    try {
        _gaq.push(['_trackPageview', '/checkout/onepage/' + section + '/']);
    } catch (err) {}

	var sectionElement = $('opc-'+section);
	sectionElement.addClassName('allow');

	var sectionElement2 = $('top-opc-'+section);
	sectionElement2.addClassName('allow');

	this.accordion.openSection('opc-'+section);
	this.reloadProgressBlock(section);
};
//]]>

Google Analytics Setup

  1. Navigate to the goal setup page: Admin > VIEW > Goals
  2. Select NEW GOAL.
  3. Goal setup: Custom
  4. Goal description Name: Checkout Success
  5. Goal description Type: Destination

Goal Details

Destination

/checkout/onepage/success/index.php

Funnel

Name URL
Cart /checkout/cart/index.php
Login /checkout/onepage/index/index.php
Billing /checkout/onepage/billing/index.php
Shipping /checkout/onepage/shipping/index.php
Shipping Method /checkout/onepage/shipping_method/index.php
Payment /checkout/onepage/payment/index.php
Review /checkout/onepage/review/index.php

Notes

  • I had to add index.php at the end of my destination URL and funnel URLs. You may not have to. Be sure to click Verify when setting up your funnel to test this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment