As you know, Google analytics is a great tool to track and analyze traffic to your website. Installing Google Analytics code may be a little tricky for new Magento users. In this tutorial for beginner, we will learn how to install Google analytics tracking code to a Magento website.
Step 1: Get Analytics Account Number
First, you will need to register for a Google analytics account at http://www.google.com/analytics/sign_up.html
Once you get the account, go to https://analytics.google.com/ for google analytics dashboard. After adding your website to Google Analytics, we will need to find Account Number (ID). Navigate to Admin > User Management > Tracking info > Tracking code section, you will see your Account number here
Step 2: Insert account ID to Magento
After getting Account ID, we will use this ID in Magento to enable tracking. In your Magento backend, go to System > Configuration > Sales > Google API
Now, select Yes in Enable field, enter the code we obtain at step 1 and save changes
Now the Google Analytics tracking code is added to your website
Step 3: Check if the code is installed properly
Open your Magento site homepage and Inspect its code (shortcut F12).
Scroll down you will see a code like this installed to your site
<!-- BEGIN GOOGLE UNIVERSAL ANALYTICS CODE -->
ga('create', 'UA-85961389-1', 'auto');
<!-- END GOOGLE UNIVERSAL ANALYTICS CODE -->
You can see the line: ga('create', 'UA-85961389-1', 'auto'); with your Analytics Account ID inside.
Hope you enjoy this quick tutorial, feel free to let me know if you have any questions.