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 3
Google Analytics not working and Spoke with Google. 
 
karynn
Member
 
Avatar
Total Posts:  70
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:  70
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:  70
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:  70
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: 593)
 
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:  9
Joined:  2007-09-04
 
etho201 - 19 April 2008 02: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
 
Appmerce
Guru
 
Avatar
Total Posts:  376
Joined:  2008-05-13
Amsterdam, The Netherlands
 

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

 
Magento Community Magento Community
Magento Community
Magento Community
 
BruceM
Jr. Member
 
Total Posts:  16
Joined:  2008-11-02
 

I was about to use Karynn’s recommendation of editing the ga.php file when 18 hours after enabling Google Analytics and the code appearing in my page source code, google analytics was not receiving any data. Then after 24 hours my google analytics starting working (using v1.6). Maybe give google more than a few hours to process.

 
Magento Community Magento Community
Magento Community
Magento Community
 
matt1237
Member
 
Avatar
Total Posts:  70
Joined:  2008-05-15
Washington State
 
karynn - 14 May 2008 08:12 PM

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…

Do you know if this is still necessary with Magento 1.1.8 and above?

 
Magento Community Magento Community
Magento Community
Magento Community
 
hazardpro
Member
 
Avatar
Total Posts:  53
Joined:  2008-10-09
 

Hi we have the same problem, Analytics has been running fine for about a month, then suddenly stopped. We hadnt changed anything or upgraded anything.

I tried your new GA.php file but that hasnt seems to do the trick. I have also checked the account code I am using and have tried de-activated and re-enabling it via the admin.

(as I say it was all working fine for about a month).

Any ideas?

Many thanks

D

 
Magento Community Magento Community
Magento Community
Magento Community
 
key
Member
 
Avatar
Total Posts:  59
Joined:  2008-07-16
beijing.china
 

I have this problem too , I delete the google track code and enable the magento google api,one day later,my google analytics report is zero.

 
Magento Community Magento Community
Magento Community
Magento Community
 
eitai2001
Guru
 
Total Posts:  330
Joined:  2008-05-14
Johannesburg, South Africa
 
hazardpro - 06 March 2009 01:37 AM

Hi we have the same problem, Analytics has been running fine for about a month, then suddenly stopped. We hadnt changed anything or upgraded anything.

I tried your new GA.php file but that hasnt seems to do the trick. I have also checked the account code I am using and have tried de-activated and re-enabling it via the admin.

(as I say it was all working fine for about a month).

Any ideas?

Many thanks

D

I’m having the exact same issue. Worked perfect for 2 months and now just randomly died.
However when assessing the source code of my site after it loads, it shows that it is not pulling any tracking code at all,which means this line of code stopped working:
var pageTracker = _gat._getTracker(”’ . $this->getAccount() . ‘“);

basically, I just get this when you look at the code after it loads: var pageTracker = _gat._getTracker("");

It was working fine up until now, and I definitely have tracker info stored. Any assistance?

Regards

Itai

 
Magento Community Magento Community
Magento Community
Magento Community
 
rockgirl
Member
 
Total Posts:  45
Joined:  2009-08-19
 

Interestingly enough this same thing has happened to me and we’re talking years and versions later!

I did the modification to the GA page and everything is working perfectly!

Thanks

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