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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <!-- BEGIN GOOGLE UNIVERSAL ANALYTICS CODE --> <script type="text/javascript"> //<![CDATA[ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-85961389-1', 'auto'); ga('send', 'pageview'); //]]> </script> <!-- 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 Magento tutorial, feel free to let me know if you have any questions.