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:
- 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.
- When prompted select "Universal Analytics" as the tracking method, this is currently the default option for new web properties in Google
- 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.
- 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.
- Upload to your site and make sure to flush the Magento Cache so your changes come through.
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
Links to the relevant Google pages:
- About Universal Analytics
- 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!