Injected Urchin script can redirect browser to unwanted URL

I've just finished a website that uses quite a bit of Ajax. To allow page views to be counted, I called Google Analytics' _gaq() function manually. I also modified the URL passed to _gaq() to remove the #! so GA would record the page, rather than just the site, URL (though this didn't actually seem to work).

When Ghostery has GA blocking enabled, it injects a surrogate Urchin script that includes the lines

if (arguments[0][0] == '_link')
window.location.href = arguments[0][1]

If, as in my case, the URL passed in doesn't match the browser URL, the browser is redirected to this new URL, which doesn't seem ideal. The real GA script doesn't do this, though I haven't examined the older Urchin one.

This may only happen when the hash ends with a slash.

I've now removed the URL changing code from my site (as it wasn't working anyway), but it may be worth changing the script if you can so others don't trip over this.

Thanks very much for your time.
1 person has
this problem
+1
Reply