Call-back icon  Sales: Call 800.374.8146 (N America)|757.278.0920 (International)

Magento

Open Source eCommerce Evolved

Magento Forum

   
Page 2 of 2
Google Analytics not working and Spoke with Google. 
 
karynn
Member
 
Avatar
Total Posts:  69
Joined:  2008-02-07
 

Okay, so I got rid of the error by using a combination of Magento’s code and Google’s code:

<!-- BEGIN GOOGLE ANALYTICS CODE -->
<
script type="text/javascript">
var 
gaJsHost = (("https:" == document.location.protocol)
"https://ssl." "http://www.");
[removed]("\<script src=\'" gaJsHost
"google-analytics.com/ga.js\' type=\'text/javascript\'>\<\/script>" );
</script>
<script type="text/javascript">
var 
pageTracker _gat._getTracker("' . $this->getAccount() . '");
pageTracker._initData();
pageTracker._trackPageview();
</script>        
<!-- END GOOGLE ANALYTICS CODE -->

So, the part the says “[removed]” above is document . write (no spaces)!
Now I’ll wait to see if I get any data…

 Signature 

Heritage Gallery Fine Art & Frames

 
Magento Community Magento Community
Magento Community
Magento Community
 
karynn
Member
 
Avatar
Total Posts:  69
Joined:  2008-02-07
 

Yup, the above code is working for me…

 Signature 

Heritage Gallery Fine Art & Frames

 
Magento Community Magento Community
Magento Community
Magento Community
 
bowers2000
Jr. Member
 
Total Posts:  27
Joined:  2008-05-21
 

Is this still working for you?  I did it and it still isn’t showing tracking in my account.  If I look at the page source data it’s showing up.

Any suggestions?  shop.halloweenhallway.com

 
Magento Community Magento Community
Magento Community
Magento Community
 
karynn
Member
 
Avatar
Total Posts:  69
Joined:  2008-02-07
 

Try this (remove the spaces between document . write) also keep each statement on one line… it is wrapping below:

<script type="text/javascript">
var 
gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." "http://www.");
document write(unescape("&#x3C;script src='" gaJsHost "google-analytics.com/ga.js' type='text/javascript'&#x3E;&#x3C;/script&#x3E;"));

<
script type="text/javascript">
var 
pageTracker _gat._getTracker("' . $this->getAccount() . '");
pageTracker._initData();
pageTracker._trackPageview();
</script>       
<!-- END GOOGLE ANALYTICS CODE -->

Then Refresh your Cache and make sure your source looks okay.

 Signature 

Heritage Gallery Fine Art & Frames

 
Magento Community Magento Community
Magento Community
Magento Community
 
bowers2000
Jr. Member
 
Total Posts:  27
Joined:  2008-05-21
 

Thanks for responding.

Unfortunately, that crashed the site. 

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /nfs/c01/h04/mnt/44763/domains/shop.halloweenhallway.com/html/app/code/core/Mage/GoogleAnalytics/Block/Ga.php on line 133

Any other ideas?  Could it be a different configuration I have that is causing the problem?  Maybe this is a symptom not the cause?

 
Magento Community Magento Community
Magento Community
Magento Community
 
karynn
Member
 
Avatar
Total Posts:  69
Joined:  2008-02-07
 

Sorry, I’m at work and was juggling several things...and forgot that I had to escape out the single quotes in the PHP file. So, I’ll just go fetch my file directly…

Please see attached. (Make a copy/rename your original file, do not overwrite it!)

File Attachments
Ga.php  (File Size: 6KB - Downloads: 42)
 Signature 

Heritage Gallery Fine Art & Frames

 
Magento Community Magento Community
Magento Community
Magento Community
 
bowers2000
Jr. Member
 
Total Posts:  27
Joined:  2008-05-21
 

You ROCK! 

Thank you it worked.  =)

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 2 of 2
 
Sales: Call 800.374.8146 (North America) 757.278.0920 (International)
© Copyright 2008 Varien. Magento is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
33676 users|422 users currently online|74651 forum posts