How do I add universal analytics to my magento store?

You have to add the new Universal Analytics code your your head.phtml file in your template. You can choose to disable the Google API or keep it active as well.

Your head.phtml file is located at: app/design/frontend/base/default/template/page/html/head.phtml

Just copy to your theme: app/design/frontend/your_theme/default/template/page/html/head.phtml

Add your analytics code before the if it shows otherwise at the end.

Here is a picture tutorial on how to do that: http://www.savethemage.com/blog/how-to-add-googles-universal-analytics-to-your-magento-store/

For tracking goals, you will have to set a new goal for your new profile.

Here is a tutorial on how to create the standard checkout goal funnel for Magento onepage abandonment rates: http://www.savethemage.com/blog/tracking-magento-onepage-abandonment-using-google-universal-analytics/


Universal analytics isn't yet supported out of the box in Magento (as at CE 1.7), so to add it to your site you need to modify your site theme.

The Universal Tracking code is also compatible with the old code, so if you are adding this to an existing site the Google recommendations are to start by running them both together to make sure there are no gaps in your records, you can then switch off the old one once you're happy with the new system.

Essentially the minimum you need to do is:

  1. Login to Google Analytics and create a new web property. This new property will capture the Universal Analytics, your old property will hold your historical data.
  2. When prompted select "Universal Analytics" as the tracking method, this is currently the default option for new web properties in Google
  3. You'll be presented with tracking code, you need to add this to your current Magento theme just before the closing tag in your theme.
  4. To add it to your theme look in app/design/frontend/<YOURTHEME>/default/template/page/html/head.phtml edit this file and paste the tracking code at the end of it.
  5. Upload to your site and make sure to flush the Magento Cache so your changes come through.

Alternative Method

If you are not comfortable editing theme files in step (4) you can instead add this code through the configuration settings of your store.

Log into your magento admin and look in System > Configuration > Design > HTML Head there's a box called "Miscellaneous Scripts" that you can add the tracking code to, any script in this box appears just before the closing </head> tag.

More information

Links to the relevant Google pages:

  1. About Universal Analytics
  2. Setting up Universal Analytics - note the "Best practices" section on this page that talks about running the old and new code concurrently as Universal is still in it's early days!