views:

42

answers:

1

We have been successfully running a Django site for a couple of years. We use the following (standard) google analytics code for most of our pages.

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>

In Django the settings are such that we get an email every time there is a broken link. Recently, one of our users has been generating a lot of broken links that are related to google analytics. The error messages look similar to this (where apage is any url):

Referrer: http://ourwebsite.com/apage/
Requested URL: /apage/.google-analytics.com/ga.js
User agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322) IP address: 127.0.0.1

Based on the error message, I suspect the problem is related to IE8 and some security settings or modes. I have tried running the Utilu IE Collection version of IE8 to reproduce the problem, but had no luck.

Any help would be appreciated.

+1  A: 

I'd guess at an operator precedence bug/quirk, as it looks that

('https:' == document.location.protocol ? 'https://ssl' : 'http://www')

(at line 8 of your snippet) may be parsed as

('https:' == (document.location.protocol ? 'https://ssl' : 'http://www'))

which would evaluate to 'https:' == 'https://ssl' and to false,

whereas the correct intent seems to be

(('https:' == document.location.protocol) ? 'https://ssl' : 'http://www')

What happens when you force the precedence with parentheses (see previous line)?

Piskvor
That line is from the standard GA async snippet; it looks unmodified, so it seems likely that some individual has very, very funky settings messing with his JavaScript. That user is likely getting errors in the background all around the internet. It could be an intentional hack, to prevent sites from successfully tracking the user using GA (which is unnecessary, since there is now a GA opt out)
yc
Yes - the GA snippet is unmodified. You are prob right about the funky settings. The question is what to do about them. I like getting emails about real broken links. I do not want to turn off the notification.
Chuck