|
Monday, May 17, 2010
Google Analytics Not Working With Magento
We were having a heck of a time trying to figure out why Google Analytics wasn’t capturing any data with a new Magento eCommerce (V 4.1) website we just built.
We added the Google Analytics account ID within the admin area, but no results.
We then noticed the error:Â _gaq is not defined being displayed from the browser.
Searching through the Magento community, Google search and blogs we were given various fixes and advice that suggested replacing the original code or updating the Magento core files. We did not want to change the existing code or core files because we wanted our client to be able to use the eCommerce portion of Google Analytics with Magento and we’re suspect about some of the fixes.
So we took matters into our own hands.
Since the error was not being defined, we defined it.
- Open /app/design/frontend/default/yourtemplate/page/html/head.phtml
- Add the code
var _gaq = _gaq || []; on line #38 to the head tag of the head.phtml file after var BLANK_IMG = '<?php echo $this->helper('core/js')->getJsUrl('spacer.gif') ?>';
- Refresh your Magento Cache
- In a few hours Google Analytics should start registering your data.
I hope this helps others who may be experiencing the same issue.
Posted by: Michael Swartz at 4:55 pm
Comments: None | Filed under: HTML, SEO, Web Design
|
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed