Magento Google Analytics goals setup

Ok... let's get right into it...

We'll assume you already have google analytics setup and working with magento...

So... we want to add Google Analytics Goals so we can track what people are doing at the different steps of checkout.

Alright... here we go...

  1. Log into your Google Analytics account
  2. Click "Admin" at the top right (of the new version of Google Analytics)
  3. Click the name of your domain
  4. Click "Goals" tab--towards the middle of page
  5. Click one of the non used "+ Goal" links
  6. Now we fill in all the info...

    Goal Name: Successful Purchase
    Select "Active"
    Goal Type: URL Destination
    Goal URL: /checkout/onepage/success/
    Match Type: Head Match
    Case Sensitive: do not check
    Goal Value: 0
    Use funnel: Select this (check it)
    Click "+ Goal Funnel Step" about 6 times to have a total of 7 steps.
    Step 1: URL: /checkout/cart/ Name: Cart
    Step 2: URL: /checkout/onepage/ Name: Checkout Start
    Step 3: URL: /checkout/onepage/billing/ Name: Billing Address
    Step 4: URL: /checkout/onepage/shipping/ Name: Shipping Address
    Step 5: URL: /checkout/onepage/shipping_method/ Name: Shipping Method
    Step 6: URL: /checkout/onepage/payment/ Name: Payment Method
    Step 7: URL: /checkout/onepage/review/ Name: Review/Confirm PRE-Payment

  7. Click "Save" ... You're almost done.
  8. Now we alter the onepage.phtml
    1. copy /app/design/frontend/base/default/template/checkout/onepage.phtml
    2. paste into /app/design/frontend/default/YOURTHEME/template/checkout/onepage.phtml
  9. Now paste this code to the bottom of the "onepage.phtml" page you just copied:
    <script type="text/javascript">
    Checkout.prototype.gotoSection = function(section) {
    try {
    _gaq.push(['_trackPageview', '<?php echo $this->getUrl('checkout/onepage'); ?>' + section + '/')]);
    } catch(err) { }
    section = $('opc-'+section);
    section.addClassName('allow');
    this.accordion.openSection(section);
    };
    </script>
  10. Save the changes (upload to server)... and SHAZAM!! you're set...!

Now you'll be able to see what your users are doing at checkout and at what step they may be exiting if they don't complete checkout....

Tags: magento google analytics