How to add Google Analytics code in Magento
Hello dear readers.
As today’s article belongs to «Learning Sessions» rubric we’ll teach you some useful things as usually.
Well, the last post was devoted to CS-Cart and showed how to easy organize that CMS based theme «5 Useful Must-Know Tips for Your CS-Cart Theme Organization». Current tutorial will show you how to add Google Analytics code in Magento.
Let’s start!
1. First of all, you need to obtain your tracking code inside your Google Analytics account.
The detailed instructions on how to do it find here
2. After having got the necessary code, please copy and paste it into Notepad editor. It should look like this:
<script>
(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-53657469-1’, ‘auto’);
ga(‘send’, ‘pageview’);
</script>
UA-53657469-1 in your code is your Account ID. 53657469-1 signify your Account ID number.
3. Login to your Magento Admin panel and go to System -> Configuration -> Google API
4. Expand the «Google Analytics» section, enable Google Analytics (1), choose type — «Google Analytics» (2), insert your Account ID into «Account Number» field (3) and press «Save Config» button (4)
5. Also you can see our video manual on this topic.