How to Enable Google Analytics

Posted in Magento tips & tricks on January 4, 2011 0 comment(s)  

Google Analytics is one of the most popular analytics engines for understanding what’s happening on a website.  Magento Commerce includes Google Analytics code, so all you have to do is enable the functionality and enter your Google Analytics account ID.

Where to find your tracking code within Google Analytics

To access your tracking code from within your Google Analytics account:

  1. Log in to Google Analytics at
  2. From the Overview page, select the account that has the profile for the tracking code you’re looking for, as the code is profile-specific.
  3. Select the profile from the accounts Overview page.
  4. From that profile’s Actions column, click Edit
  5. At the top right of the ‘Main Website Profile Information’ box, click Check Status
  6. Your tracking code can be copied and pasted from the text box in the Instructions for adding tracking section

The tracking/account ID has two parts:

  • the X’s (UA-XXXXXXXX-YY) represent your account number
  • the Y’s (UA-XXXXXXXXX-YY) represent profile numbers within your account.

The complete string (UA-XXXXX-YY) is referred to interchangeably as your web property ID or UA number

Where to add your Google Web Property ID or UA within Magento

  1. Login to your Magento Admin Area
  2. Navigate to System -> Configuration -> Google API
  3. Choose the ‘Configuration Scope’ from the drop down in the top left of the page.  As with most options for Magento Commerce, value and settings can be set at the global level (Default Config), Website level, or the Store View level.  Depending on how you want to track your Magento installation using Google Analytics depends on the scope you choose.  If you have one Google Analytics profile with a single UA number, then choose the “Default Config” scope and your Google Analytics account will report against all Websites and Store Views as one.  If you only have 1 website and 1 store view configured within Magento then choose this option.  If you want to monitor each Magento Website individually you need to have multiple Google Analytics Profiles, one profile for each Magento Website.  Each Profile creates a unique key so you can generate a Google API UA Number for each website you wish to monitor.  If you want to go one step further and track each store view within Google Analytics you need to generate one Google Analytics Profile for each Magento Store View, then choose the appropriate ‘Store View’ from the drop-down within Magento.
  4. Expand the “Google Analytics” area and you’ll see a drop-down which allows you to enable or disable Google Analytics tracking.  You’ll also see a text input area labeled “Account Number” which is where you need to insert your Google web property ID/UA number.
  5. Save the configuration and you’re done

Note to users

If you are using Magento Commerce you need to be aware that Google Analytics is broken in this version because of Bug ID 8658.  You can read and track this bug here –

The issue is resolved in and later and doesn’t affect or earlier.  The fix is very simple to implement.  Edit app/code/core/Mage/GoogleAnalytics/Block/Ga.php and on line 179 add:

var _gaq = _gaq || [];

Alternatively download the fixed version from SVN


This post was posted in Magento tips & tricks and was tagged with Magento tutorials

Leave a comments
Your email address will not published. Required fields are marked *

What Our Clients Say?

  • Oscar Soto MANAGER
    ArrowHiTech has always impressed me! They are professionals and are quick to response to my needs. I have used
    them in the past and will continue to use them in the future. Thanks Martin and all the Staff at ArrowHiTech!!!
  • The guys of AHT solutions did a perfect job and are real profesionals. Definitely recommend them and will use them again!
  • Jonatas Leonel MANAGER
    Martin has a great team of Magento experts, I really liked the work he did for me. I asked him to customize my template following a couple of jpg files that I got from a designer and he worked on that template without the psd's - that was awesome, the result I got was really good.
  • I really enjoy working with ahtsolutions. Quick response to our questions, delivery the project in time and excellent skills. I hope to work with them soon
Request us now! Yahoo:gravitational_boy Skype:hyun_yoo_it +84437955813