Google Analytics E-commerce Not tracking. I know why but don’t know how to fix. 

Please LogIn to Reply!

Post By: admin | 26-01-2012 06:35 Reply

 

I’ve been trying to get e-commerce tracking working for my client. There’s a common issue I found while looking through these forums but that’s NOT the problem.

I followed the suggestions here:
http://www.magentocommerce.com/bug-tracking/issue/?issue=8492

And Here:
http://www.magentocommerce.com/boards/viewthread/23325/P15/

But that wasn’t my issue. My GA.php was up to date and it is displaying the products code, and the “var _gaq = _gaq || [];” is already loading.

No javascript errors when I checkout either. So I created a test page until I got the ecommerce to work .. The problem is and I don’t know how to fix is that my analytics code is loading in the header and loading in the footer
Header loads::

<script type="text/javascript">

 var 
_gaq _gaq || [];      
 
_gaq.push(['_setAccount''UA-XXXXXXX-X']);
_gaq.push(['_trackPageview']);

  (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 
document.getElementsByTagName('script')[0]s.parentNode.insertBefore(gas);
 
})();

</script>
<!-- BEGIN GOOGLE ANALYTICS CODE -->
<
script type="text/javascript">
//<![CDATA[
    
(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);
    
})();

  var 
_gaq _gaq || [];
  
_gaq.push(['_setAccount''UA-XXXXXX-X']);
  
_gaq.push(['_trackPageview']);
 
_gaq.push(function() {
    
// the global variable is created intentionally
  
pageTracker _gat._getTracker('UA-XXXXXX-X');
  
pageTracker._trackPageview();
 
});

_gaq.push(['_addTrans''111111''-''xx''xx''1xx''xxa''xx''xx']);
_gaq.push(['_addItem''1111''xxx''xxx''''1xx''1.0000']);
_gaq.push(['_trackTrans']);
//]]>
</script>
<!-- END GOOGLE ANALYTICS CODE -->

And in the footer it loads the following code:
<script type="text/javascript"
 
  var 
_gaq _gaq || [];
  
_gaq.push(['_setAccount''UA-xxxxxx-x']);
  
_gaq.push(['_trackPageview']);
 
  (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 
document.getElementsByTagName('script')[0]s.parentNode.insertBefore(gas);
  
})();
 
</script>

This is being auto-generated by magento. I set up a test page, removed the footer code and viola! The e-commerce tracks perfectly! It seems like the double loading of the analytics code is causing the issue. My problem is. How the heck do I get that to NOT load in the footer on the checkout success page? I’m not sure. Can anyone help??

`Reply Or Comment!
Please LogIn to Reply!