Google Analytics Setup in Magento eCommerce

Posted by Damodar Bashyal on October 20, 2011

 

Installing Google Analytics is quite simple in Magento e-Commerce. Copy your Web Property ID from Google Analytics Settings > Tracking code. It looks like UA-852764-24

Now goto:

System > Configuration > Google API > Google Analytics.

Enable the google analytics and insert the google web property id on Account Number which is like UA-xxxxxx-xx as mentioned previously.

NOTE: The Google Analytics implementation is broken in Magento 1.4.0.0 and 1.4.0.1 versions.

So, to fix this, copy:

app/code/core/Mage/GoogleAnalytics/Block/Ga.php

to local at:

app/code/local/Mage/GoogleAnalytics/Block/Ga.php

Then at line 179 add below code:

var _gaq = _gaq || [];

That's just before this line:

_gaq.push(["_setAccount", "' . $this->getAccount() . '"]);

Now, Everything seems fine as I wanted except it's appearing on the footer rather than on head. So, now time to move it to head.

On your design > layout copy googleanalytics.xml file and replace:

	<reference name="after_body_start">
//to
	<reference name="head">

Now clear your cache. I like to cleanup from command line as:

~/public_html/var/cache]# rm -rf mage--*

That will clean every single trace of previous cache.

Yohooo! It's now appearing on head with corrected code. Did you enjoy the POST?

If you did please post your comment and like us.

MS Accounting Software posted on - Tuesday 4th of December 2012 11:11:10 AM

Thanks for this Google Analytics to Magento guide! :)
 
not published on website


QR Code: Google Analytics Setup in Magento eCommerce