Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Google analytics not working
 
XPSM1730
Member
 
Total Posts:  70
Joined:  2008-02-27
 

I’ve enabled google analytics API 7 days ago in the magento admin panel, but in google analytics the ticker stays at 0.
Is this a common issue?

 
Magento Community Magento Community
Magento Community
Magento Community
 
XPSM1730
Member
 
Total Posts:  70
Joined:  2008-02-27
 

Anyone?
The google account number is in this format right? UA-XXXXXX

Also, at the online customers section i get to see this a lot.

http://www.mywebsite.com/"%20+%20gaJsHost+%20"google-analytics.<br />com/"%20+%20gaJsHost+%20"google-analytics.com/"%20+%20gaJsHo<br />st+%20"google-analytics.com/"%20+%20gaJsHost+%20"google-anal<br />ytics.com/"%20+%20gaJsHost+%20"google-analytics.com/"%20+%20<br />gaJsHost+%

 
Magento Community Magento Community
Magento Community
Magento Community
 
intensity
Member
 
Total Posts:  48
Joined:  2008-11-22
 

I’ve encountered the very same problem.  Unfortunately I have a feeling this problem will be hard to resolve.

 
Magento Community Magento Community
Magento Community
Magento Community
 
skippybosco
Enthusiast
 
Avatar
Total Posts:  796
Joined:  2008-10-03
 

A couple of things:

1) Did you refresh your cache after enabling google analytics
2) My Google Analytics code looks like this: UA-123456-78. Are you missing the last 2 digits perhaps?
3) When you “view source” of your page do you see the google analytic tags:

<!-- BEGIN GOOGLE ANALYTICS CODE -->
<
script type="text/javascript">
//<![CDATA[
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." "http://www.");
[removed](unescape("&#x3C;script src='" gaJsHost "google-analytics.com/ga.js' type='text/javascript'&#x3E;&#x3C;/script&#x3E;"));
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
var pageTracker _gat._getTracker("UA-######-##");
pageTracker._trackPageview("/");
//]]>
</script>
<!-- END GOOGLE ANALYTICS CODE -->
 
Magento Community Magento Community
Magento Community
Magento Community
 
intensity
Member
 
Total Posts:  48
Joined:  2008-11-22
 

This is what my code looks like but it’s still not working.  It’s a bit different from yours.  I did modify it a bit with the advise from a previous thread. 

<!-- BEGIN GOOGLE ANALYTICS CODE -->
<
script type="text/javascript">
var 
gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." "http://www.");
[removed](unescape("&#x3C;script src='" gaJsHost "google-analytics.com/ga.js' type='text/javascript'&#x3E;&#x3C;/script&#x3E;"));
</script>
<script type="text/javascript">
var 
pageTracker _gat._getTracker("UA-#######");
pageTracker._initData();
pageTracker._trackPageview();
</script>        
<!-- END GOOGLE ANALYTICS CODE -->
 
Magento Community Magento Community
Magento Community
Magento Community
 
DCAlmeida
Sr. Member
 
Avatar
Total Posts:  164
Joined:  2008-12-28
PRT
 

I knowed the existing of something about analytics in Magento. Today I searched where configure this and I founded.
And is so simple, just enter the own code: UA-XXXXXXX-XX

I don´t know what´s your problem…

 
Magento Community Magento Community
Magento Community
Magento Community
 
redvinny
Member
 
Total Posts:  48
Joined:  2008-11-22
 

It could be that you are not using the xml footer that magento provides (if they insert it before the </body> tag).  Can someone confirm where in the code magento places the google tracking code?

I too have activated the google api in the backend but no tracking appears in the front end when viewing source.  You can get around this by inserting the tracking code into your 1,2 and 3 column.phtml files - this way it is hard coded into your site.

 
Magento Community Magento Community
Magento Community
Magento Community
 
pdatoon
Sr. Member
 
Total Posts:  107
Joined:  2008-10-22
 

Hmmm i have the pb. I can see the GA code fine, but in my GA account, i have no data. weird

 
Magento Community Magento Community
Magento Community
Magento Community
 
SCompany
Jr. Member
 
Avatar
Total Posts:  20
Joined:  2009-09-17
 

I’ve had a similar problem with the Modern template in magento 1.4. Yesterday I decided to backup the Ga.php file in

app/code/core/Mage/GoogleAnalytics/Block
and use the version from magento 1.3.2.1. 
This seamed to help, now all the data is showing up in my Google Analytics Dashboard.

Hope this helps anyone

 
Magento Community Magento Community
Magento Community
Magento Community
 
a1anm
Guru
 
Total Posts:  318
Joined:  2009-10-08
 

This fixed it for me:

Go to line 170 in
app/code/core/Mage/GoogleAnalytics/Block/Ga.php

and replace the block with:

$this->addText(’
<!-- BEGIN GOOGLE ANALYTICS CODE 1-->
<script type="text/javascript\">
//<![CDATA[
var _gaq = _gaq || [];
_gaq.push(["_setAccount", ”’ . $this->getAccount() . ‘“]);
_gaq.push(["_trackPageview", “‘.$this->getPageName().’"]);

(function() {
var ga = document.createElement(\’script\’); ga.type = \’text/javascript\’; ga.async = true;
ga.src = (\’https:\’ == document.location.protocol ? \’https://ssl\’ : \’http://www\’) + \’.google-analytics.com/ga.js\’;
(document.getElementsByTagName(\’head\’)[0] || document.getElementsByTagName(\’body\’)[0]).appendChild(ga);
})();

//]]>
</script>
<!-- END GOOGLE ANALYTICS CODE -->

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top