Call-back icon  Sales: Call 877.832.5289 (N America)|310.295.4144 (International)

Magento

eCommerce Software for Online Growth

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…

 
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…

 
Magento Community Magento Community
Magento Community
Magento Community
 
bowers2000
Member
 
Total Posts:  31
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.

 
Magento Community Magento Community
Magento Community
Magento Community
 
bowers2000
Member
 
Total Posts:  31
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: 90)
 
Magento Community Magento Community
Magento Community
Magento Community
 
bowers2000
Member
 
Total Posts:  31
Joined:  2008-05-21
 

You ROCK! 

Thank you it worked.  =)

 
Magento Community Magento Community
Magento Community
Magento Community
 
ramirors
Jr. Member
 
Total Posts:  8
Joined:  2007-09-04
 
etho201 - 19 April 2008 03:19 AM

I’ve noticed that Google Analytics tells you that your account number is XX-XXXXXXX but then when they tell you to paste code to your page they tell you to paste it as XX-XXXXXXX-1… and that worked for me, as soon as I put the -1 at the end of my account number in the Magento admin everything works fine.

This works for me, just check the code gerated from GA, and verify de “-XX”, use this Google ID on magento

 
Magento Community Magento Community
Magento Community
Magento Community
 
Morningtime
Member
 
Avatar
Total Posts:  54
Joined:  2008-05-13
Munich
 

Problem still exists in Magento 1.1.6 - using Karynn’s fix it works.

 Signature 

Morningtime Network :: Working with Magento since 2008. (Dreaming about it since 1980.)

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 2 of 2
 
Sales: Call 877.832.5289 (North America) 310.295.4144 (International)
© Copyright 2008 Varien. Magento, eCommerce software, is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
52318 users|443 users currently online|105656 forum posts