homepage Welcome to WebmasterWorld Guest from 54.227.67.210
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Google Analytics code and 404
404 problems with Google Analytics code
smallcompany




msg:3783257
 7:08 am on Nov 10, 2008 (gmt 0)

I've been having GA in some of my sites for quite a bit. I used both old and new code.

In both cases, I have always been getting 404 as client would try to load ga.js script from the local server, rather then from Googles site where the client is supposed to go.

I thought about downloading the script and have it as local on my server, but I saw a lot of content and links there which made me abandon this idea. Still, I want to comment on the content of that file which is a full regular HTML page, plus the JavaScript code. Why is that?

Anyhow, my main problem is that I get such 404s:

mysite.com/folder-if-any/ga.js

I wonder if I could fix the script by changing this part:

src='" + gaJsHost + "google-analytics.com/ga.js'

into something like this:

src='http://www.google-analytics.com/ga.js'

...so I ensure the client goes to Google to load the script.

I get an email every time 404 occurs and I like that. But, those GA related 404s are really annoying.

I did ask Google directly, and posted a question under AdWords some tie ago, but no help or explanation has come out.

Any comment is much appreciated.

Thanks

 

SEOMike




msg:3784479
 11:31 pm on Nov 11, 2008 (gmt 0)

Changing the call to go directly to Google should fix the issue and should be how it was given to you originally in google analytics. I have downloaded the script for some of my sites and call it locally just fine so that avenue would work too. You should use your full URL to avoid issues with a relative call.

smallcompany




msg:3784552
 2:43 am on Nov 12, 2008 (gmt 0)

Thank you very much.

The source I have put here is how it is from GA. I wonder if site search being turned on could cause it. I'll check with them.

In regards of the local call, I was afraid of doing it as I saw extra references back to Google, with relative paths (new GA script).

Ill see if I can fix it by still having it going to Google.com

Thanks again for clarification.

pageoneresults




msg:3784559
 3:04 am on Nov 12, 2008 (gmt 0)

Changing the call to go directly to Google should fix the issue and should be how it was given to you originally in google analytics.

I too would like to see confirmation on this. The original GA code from Google is given to you like this...

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-0101010-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>

We have continual challenges in this area with a small percentage of 404s being generated throughout the day on various sites that use the new GA code. I too have previous topics on this that were never really answered.

Personally I believe it is a fail safe to prevent your page from being delayed if there are any performance issues from the GA servers. With the old code, if you had it before your primary content, the page would be delayed while the GA code finished loading. I think the new code provides a fail safe that if the GA server takes too long, it returns a 404 and appends the URI where the 404 took place. I also get emails...

/sub/sub/sub/google-analytics.com/ga.js

In fact, I just got four of them from one site. Pesky little buggers. ;)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved