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

Page 1 of 2
v 1.7.0 Google Analytics codes missing from all pages
 
marktruswell
Jr. Member
 
Total Posts:  3
Joined:  2012-04-26
 

Hi,

On a new installation of v1.7.0 the GA codes are not appearing on any page.

I have installed the JewelryMoon template from Megastore and checked that it does have the \\\"before_body_end\\\" and it does exist in the .phtml and page.xml files.

The correctly formatted UA-XXXXXX-1 is in the system configuration and Google Analytics is enabled.

Any ideas? What is the best way to debug this?

Thanks,
Mark.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Tom Robertshaw
Guru
 
Avatar
Total Posts:  485
Joined:  2009-05-17
Bath, UK
 

Have you checked the EU cookie law settings?  Functionality was added in 1.7 that the Google Analytics code would only be outputted on the page if the user had accepted a message requesting the use of cookies. 

If you don’t have this enabled and you are using a custom theme, then you might need to check if there’s any conflicts around this area of code.

 
Magento Community Magento Community
Magento Community
Magento Community
 
marktruswell
Jr. Member
 
Total Posts:  3
Joined:  2012-04-26
 

Hi,

Thanks for responding. I’ve checked and ‘Cookie Restriction Mode’ is set to ‘No’.
I’ve also reverted to the default theme and its not working for that, so I guess its not template related.
I’ll have to try to debug this one somehow or try a fresh install.

Thanks again.

 
Magento Community Magento Community
Magento Community
Magento Community
 
adrock5150
Member
 
Total Posts:  32
Joined:  2011-01-23
Albuquerque, NM
 

where is the setting to turn off cookie mode?

 
Magento Community Magento Community
Magento Community
Magento Community
 
RB2009
Member
 
Total Posts:  40
Joined:  2010-12-05
 

Hi, its not working on here either :(

I tried the default built in Magento themes also.

and cookie restriction mode off.. but it refuses to work.

this is a magento bug

My temporary fix was to set all the settings up as I want it under the Google APi tab
then, view homepage source code, copy the generated google code.

add my id to that code

then disable the Google Analytics, and paste the google analytics code in the design tab under “Miscellaneous Scripts” until this problem can be resolved.. and now analytics is back working for the moment.

 
Magento Community Magento Community
Magento Community
Magento Community
 
RB2009
Member
 
Total Posts:  40
Joined:  2010-12-05
 

problem is located here,

no fix yet but im sure this is what is doing it.

looks like the problem is related to this code here,

<?php if (!Mage::helper('core/cookie')->isUserNotAllowSaveCookie()): ?>
<?php $accountId = Mage::getStoreConfig(Mage_GoogleAnalytics_Helper_Data::XML_PATH_ACCOUNT) ?>
<!-- BEGIN GOOGLE ANALYTICS CODEs -->
<script type="text/javascript\">
//<![CDATA[
var _gaq = _gaq || [];
<?php echo $this->_getPageTrackingCode($accountId) ?>
<?php echo $this->_getOrdersTrackingCode() ?>

(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’;
var s = document.getElementsByTagName(’script’)[0]; s.parentNode.insertBefore(ga, s);
})();

//]]>
</script>
<!-- END GOOGLE ANALYTICS CODE -->
<?php endif; ?>

located in

app/design/frontend/base/default/template/googleanalytics/ga.php

more specifically problem could be the code highlighted.

 
Magento Community Magento Community
Magento Community
Magento Community
 
hankzh
Member
 
Total Posts:  56
Joined:  2011-02-08
 

As I known, magento changed the way how google analytics deployed since version 1.6.
But you mentioned you only have this issue in v1.7, not v1.6.
So did you mind post the result for below two queries in your database?

select from core_config_data
where path like 
'google/analytics%'

and

select from core_resource
where code like 
'google%_setup'

RB2009 - 03 May 2012 02:57 PM

problem is located here,

no fix yet but im sure this is what is doing it.

looks like the problem is related to this code here,

<?php if (!Mage::helper('core/cookie')->isUserNotAllowSaveCookie()): ?>
<?php $accountId = Mage::getStoreConfig(Mage_GoogleAnalytics_Helper_Data::XML_PATH_ACCOUNT) ?>
<!-- BEGIN GOOGLE ANALYTICS CODEs -->
<script type="text/javascript\">
//<![CDATA[
var _gaq = _gaq || [];
<?php echo $this->_getPageTrackingCode($accountId) ?>
<?php echo $this->_getOrdersTrackingCode() ?>

(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’;
var s = document.getElementsByTagName(’script’)[0]; s.parentNode.insertBefore(ga, s);
})();

//]]>
</script>
<!-- END GOOGLE ANALYTICS CODE -->
<?php endif; ?>

located in


app/design/frontend/base/default/template/googleanalytics/ga.php

more specifically problem could be the code highlighted.

 
Magento Community Magento Community
Magento Community
Magento Community
 
seansan
Member
 
Total Posts:  62
Joined:  2010-01-27
 

We have the same issue. Tried commenting the if statement, but still no success

 
Magento Community Magento Community
Magento Community
Magento Community
 
seansan
Member
 
Total Posts:  62
Joined:  2010-01-27
 

Had a look here:

/app/code/community/Fooman/GoogleAnalyticsPlus/Block/Ga.php

and set the gaq manually

_gaq.push(["_setAccount", “‘CODE GOES HERE’"]’;

If this makes it work again then maybe its an fooman bug? The function to call / access the account ID also look like they differ; maybe thats where it goes wrong

protected function _getPageTrackingCode ($accountId$accountId2 false)
    
{
        
//url to track
        
$optPageURL trim($this->getPageName());
        if (
$optPageURL && preg_match('/^\/.*/i'$optPageURL)) {
            $optPageURL 
"{$this->jsQuoteEscape($optPageURL)}";
        
}

        
//main profile tracking including optional first touch tracking
        
$html '
            _gaq.push(["_setAccount", "' 
$this->jsQuoteEscape($accountId) . '"]';
        if (
$domainName Mage::helper('googleanalyticsplus')->getGoogleanalyticsplusStoreConfig('domainname')) {
            $html 
.=' ,["_setDomainName","' $domainName '"]';
 
Magento Community Magento Community
Magento Community
Magento Community
 
marktruswell
Jr. Member
 
Total Posts:  3
Joined:  2012-04-26
 

Hi,

I gave up with this and installed ‘Fooman_GoogleAnalyticsPlus’ (version 0.10.6 beta). This got the basic analytics working. Hope it’s fixed in a future release/patch.

Mark.

 
Magento Community Magento Community
Magento Community
Magento Community
 
tipofloe
Jr. Member
 
Total Posts:  23
Joined:  2009-02-17
 

Hello,

I too have the same problem. 

I had Analytics working fine along with the Fooman additions in ver. 1.6.2.0 and then starting the day I updated to 1.7.0, NADA.  Zilch.  Nothing. 
I too noticed that my ID is missing on all pages when only using the Google API Use analytics set to yes and code pasted properly. 

In other words, nothing’s been changed and Analytics can’t keep track.  So I disabled it and copy pasted the code and voila!  it started working immediately and I am now tracking people in real-time. 

I hope this will get fixed soon...?

 
Magento Community Magento Community
Magento Community
Magento Community
 
nogoodchoices
Jr. Member
 
Total Posts:  26
Joined:  2010-12-06
 

I had the same problem.  In my layout XML file I needed to switch the block call in <reference name="before_body_end"> from

<block type="googleanalytics/ga" name="google_analytics" as="google_analytics" />
to
<block type="googleanalytics/ga" name="google_analytics" as="google_analytics" template="googleanalytics/ga.phtml" />

Hope this helps someone.

 
Magento Community Magento Community
Magento Community
Magento Community
 
lrbisolo
Jr. Member
 
Total Posts:  1
Joined:  2012-05-12
 

This works for me! Very very thank you!

 
Magento Community Magento Community
Magento Community
Magento Community
 
jonmck
Sr. Member
 
Total Posts:  234
Joined:  2009-02-02
Birmingham, AL
 

That fixed it for me as well - thank you!

 
Magento Community Magento Community
Magento Community
Magento Community
 
riskid
Jr. Member
 
Total Posts:  1
Joined:  2012-08-06
 
nogoodchoices - 01 June 2012 06:21 AM

I had the same problem.  In my layout XML file I needed to switch the block call in <reference name="before_body_end"> from

<block type="googleanalytics/ga" name="google_analytics" as="google_analytics" />
to
<block type="googleanalytics/ga" name="google_analytics" as="google_analytics" template="googleanalytics/ga.phtml" />

Hope this helps someone.

My code said: <reference name="after_body_start"> instead of <reference name="before_body_end">

I changed it and now it seams to work.

 
Magento Community Magento Community
Magento Community
Magento Community
 
aaronwallace
Member
 
Total Posts:  59
Joined:  2011-07-18
 

If still some people are getting issues, please visit http://www.expertmagentodevelopers.com/blog/upgrading-to-magento-1-7-gives-errors/

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2