How to redirect and keep referrer data for web analytics


As many will have heard, Cool URIs Don’t Change, but in the course of the life-cycle of a typical website it invariably happens. And when it does, the only reasonable solution is to redirect users to the new location for content.

Best practice is to use a server-side 301 (permanent) redirect as this is the only reliable method that works for SEO – helping search engines update your URLs, but what happens if you use other methods? Does the same thing happen in all browsers?

This is particularly important for URLs that are entry points on your site, as without original referrer data, you cannot know the source of sales and conversions on your site. Anyway, on to the results.

Redirect referrer test results
Redirect methodBrowserResultImpact on analytics
Meta refresh – 0Firefox 3Blank referrerLost data
IE8Blank referrerLost data
Opera 9Internal referrerLost data
Javascript:location.hrefFirefox 3Internal referrerLost data
IE8Blank referrerLost data
Opera 9Internal referrerLost data
Javascript:location.replaceFirefox 3Internal referrerLost data
IE8Blank referrerLost data
Opera 9Internal referrerLost data
Server-side 301Firefox 3Original referrer 
IE8Original referrer 
Opera 9Original referrer 
Server-side 302Firefox 3Original referrer 
IE8Original referrer 
Opera 9Original referrer 
Server-side 301 – chainedFirefox 3Original referrer 
IE8Original referrer 
Opera 9Original referrer 
Server-side 302 – chainedFirefox 3Original referrer 
IE8Original referrer 
Opera 9Original referrer 

Conclusion

While there’s nothing too unexpected in the results, it’s clear that the only way to redirect visitors and have reliable web analytics data is to use a server-side redirect. No javascript or meta-based method works, in all cases resulting in an empty or internal referrer (which will misleadingly show up as bookmark/direct in most analytics packages). Interestingly, javascript and meta redirects can result in totally blank referrer data in some browsers.

Server-side methods worked across all major browser tested, and you can get away with chaining redirects together while still keeping the referrer data.

You can download a spreadsheet of results below.

Psst: I’ll also report back on how Googlebot handles spidering of the redirect tests

referral-data-redirect-tests.xls

Share this Post: Facebook Twitter LinkedIn Google Plus StumbleUpon Reddit RSSEmail