Google Analytics Full Referrer URL

January 15th, 2007

One thing that really annoys me with some vistor tracking software is that it truncates the referring url at the query string.(ie someforum.com/post.php?id=354353 show up as just someforum.com/post.php) This makes it a huge hassle to find the specific referring page that your users are coming from.

Google Analytics is a good example of tracking software that does this. In the actual javascript you can see the line of the code that truncates the url:

if (k.indexOf("?") > -1) k=k.substring(0,k.indexOf("?"));

Removing this line and hosting the javascript locally would be one solution to the problem. Google does allow you to host the javascript locally, but the line in question is below this commnent in the code:

//-- **** Don't modify below this point ***

If you are daring feel free to ignore that line and modify the code anyway. I am going to use the next method.

Another solution/hack to this problem was posted by Reuben Yau. It basically throws the full referring url into the page section of the google analytics data. Here is the official use of this feature. Reuben’s method calls for moving the analytics code in the head and calling the urchintracker a second time when the body is loaded. My modification is to keep the code in the where it is, and call the urchintracker a second time with the refferer url as the page. I also created a second profile in google analytics so the rest of my analytics statistics are not affected. It looks something like this:

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
_uacct = "UA-367787-7";
urchinTracker();
_uacct = "UA-367787-11";
urchinTracker(document.referrer);
</script>

I really think google should create an option for google analytics to avoid all this nonsense.


2 Comments to “Google Analytics Full Referrer URL”


  1. Franck said:

    Good article, but the trick sounds a little “heavy”, unfortunately. Not even sure either if Google allows this.

    One question that really bugs me is WHY in the world, almost all of the tracking software or script are doing this?
    I mean is there a security issue there in passing variables and query strings? Or it this simply a stupid “convention” that none of these software writers realized it was a nonsense?

    What is the point of having a list of referrers that looks like this:
    Referrer:
    http://www.google.com/search
    http://www.google.se/search
    http://www.google.co.cr/search
    http://www.google.co.in/search

    These people must be really dumb to produce such crappy software and think it can be useful. How the heck do you optimize a page if you don’t know what keywords your visitors are using to land on that specific page?

    It is a mystery to me.

    Anyone knows why it is this way?


  2. kbrower said:

    There are some good reasons for truncating the query string of a url. Query strings often contain extraneous information and sometimes contain sensitive user information. It is much more useful to look at statistics that list one referrer as website.com rather than a list looking something like this:
    website.com/?ssid=90437858
    website.com/?ssid=43012789
    website.com/?ssid=04371289
    website.com/?ssid=37806348

    The breaking point for Google and other companies that provide tracking software is the possibility of the query string containing sensitive information. IMO they should at least provide an option to turn off truncating the query string, or at least provide support for common forum software query strings in the same way they do for common search engines.

    I don’t know what tracking software you are using, but most of the better ones these days at least provide support for keyword analysis in all of the major search engines.

Leave a Reply