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 2 of 2
v 1.7.0 Google Analytics codes missing from all pages
 
SxN_
Jr. Member
 
Total Posts:  8
Joined:  2008-02-07
Bucharest
 
riskid - 19 August 2012 11:52 PM

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.

Good Job! riskid
I use magento 1.7.0.2 and now works

Thank you!

 
Magento Community Magento Community
Magento Community
Magento Community
 
phes
Jr. Member
 
Total Posts:  6
Joined:  2009-12-17
 

Hi
Analytics will not track correctly if placed within the body, it needs to be placed within the <head> preferably just before </head>

I am not sure how to get it to render as the last item in the head but this got it in the head for me

<reference name="head">

I have been tracking google analytics for a while with the code in the body and all seemed well until I started an adwords campaign which told me I was getting over 500 visits from a certain key word, but there was no evidence of this from the data collected in analytics, I have moved the code to the head as instructed from Google Adwords Support and will report back if this improves data collection

 
Magento Community Magento Community
Magento Community
Magento Community
 
smg1965
Jr. Member
 
Total Posts:  24
Joined:  2009-03-30
 

I had this problem suddenly happen and inserted the tracking code into System->General->Design->Footer->Miscellaneous HTML which seemed to work ...

The problem, after a good look, turned out to be having ‘Cookie restriction mode’ turned on and the culprit being the if statement as mentioned below. Delete the if statement and it now works fine. Be sure to make a copy in your theme folder.

<?php if (!Mage::helper('core/cookie')->isUserNotAllowSaveCookie()): ?>
and
<?php endif; ?>
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
 
ankur_jain85
Jr. Member
 
Total Posts:  6
Joined:  2011-07-05
 

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" />

This code works for me for Magento 1.7, Thanks for the post “Nogoodchoices”....

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