What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 131 Stack Exchange communities.

Running IE8. I see, in Fiddler, the ga.js script being loaded, but still '_gat' is undefined. I recently reset the browser per: http://social.answers.microsoft.com/Forums/en-US/InternetExplorer/thread/ca20f06a-49c4-4a52-8b79-2bdc283fd82c though I suspected it was bogus ("IE is somehow got corrupt.." i don't think so).

EDIT: I shouldn't have said i get this on other sites, I should have said, I have noticed it on other sites. I don't currently have another site that is experiencing this issue. It looks like it's just the way the javascript is put on the page and the order in which IE8 is executing and loading scripts... on stackoverflow.com you have:

<script type="text/javascript">
    document.write(unescape("%3Cscript src='http://www.google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
    var pageTracker = _gat._getTracker("UA-5620270-4");
    pageTracker._trackPageview();
</script>

And the first script is not loaded at the time of trying to access _gat.

In my opinion, and I'm not a javascript expert, the document.write is either not happening first or is happening, but not causing the script to get loaded in time.

Also, wouldn't it be better to have a try/catch around your _gat code in case it were currently unavailable?

share|improve this question
    
On which pages does this error occur? All of them? Also, what happens? Are the pages unusable, or are features unavailable, etc.? –  Jon Seigel Jul 9 '10 at 17:42
    
Occurs on all pages, though they are still usable. However, all the ajax features stop. –  matt-dot-net Jul 9 '10 at 17:47
    
Hmmm... well, considering this same error happens on sites other than Stack Overflow, I suspect it's a problem isolated to your computer/browser. So there's really nothing we can do about it here. –  Jon Seigel Jul 9 '10 at 19:25
    
Well, the problem is gone - guess someone changed something –  matt-dot-net Jul 12 '10 at 3:52

3 Answers 3

up vote 0 down vote accepted

I can't reproduce this in IE8.

share|improve this answer
    
8.0.7600.16385 The only addons enabled are flash and silverlight. Disabling those did not help –  matt-dot-net Jul 9 '10 at 21:00
    
neither can i any longer –  matt-dot-net Jul 12 '10 at 3:52

Seems your Proxy server is denying the script ga.js to be downloaded. This will throw a runtime exception because _gat is defined in ga.js and used inside the web page.

share|improve this answer
    
no proxy server that I'm aware of. When I watch the traffic in fiddler, I see the script get downloaded just fine. –  matt-dot-net Jul 10 '10 at 1:09

(Another possibility) This sometimes happen because ga.js is not yet loaded. You may

Add a delay:

<script type="text/javascript">
    var pageTracker;

    setTimeout('startGA();', 500);
    function startGA()
    {
        pageTracker = _gat._createTracker("UA-XXXXXX-X");
        pageTracker._trackPageview(); 
    }
</script>

--- credits of above codes snippet from this link

Or a better way:

would be to define pagetracker onload

<script type="text/javascript">
    var pageTracker;

    $(window).load(function(){ 
        pageTracker = _gat._createTracker("UA-XXXXXX-X");       
        pageTracker._trackPageview(); 
    });
</script>

To check whether ga.js is loaded

You may also do this (instead of try catch):

<script type="text/javascript"> 
    var pageTracker;

    if (typeof(_gat) == "object") { 
        pageTracker = _gat._createTracker("UA-XXXXXXX-X"); 
        pageTracker._trackPageview(); 
    } 
</script> 

Just a note - I would recommend the declaration of var pageTracker to be outside of try-catch block or if/else statement. Hope this helps someone.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .