Forum Moderators: coopster

Message Too Old, No Replies

What is the best way to get the referrer?

         

Patrick Taylor

10:49 am on Dec 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$_SERVER['HTTP_REFERER']

This doesn't record all referrers. Is there a better way?

eg: $HTTP_ENV_VARS["HTTP_REFERER"]

macdave

2:22 pm on Dec 9, 2004 (gmt 0)

10+ Year Member



Can you expand on "doesn't record all referrers"?

In my experience, if the browser is sending a referrer, it will be in $_SERVER['HTTP_REFERER'] Of course, not all browsers send a referrer (such as anonymizing proxies), and there a cases where there is no referrer to send (bookmarks, typed-in URLs, etc.). In those cases, $_SERVER['HTTP_REFERER'] is not set.

Patrick Taylor

3:10 pm on Dec 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What I mean is that my tracking system doesn't show a referrer in all cases, and I wondered if there was a more reliable way to record it (even though the referrer is not always available to be recorded).

jatar_k

5:58 pm on Dec 9, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> This doesn't record all referrers.

and it never will, getting in the 90% range is the best you can hope for usually. Too many things that block referers and sometimes they just aren't there.

If you can get a large percentage of the referers it is honest to extrapolate that against gross traffic or just work with percentages at that point.

Patrick Taylor

6:35 pm on Dec 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for the confirmation. I'm pleased to know I'm doing it correctly, i.e. with $_SERVER['HTTP_REFERER'] and that I'm not missing some other better-performing variable.

Patrick

macdave

7:06 pm on Dec 9, 2004 (gmt 0)

10+ Year Member



In terms of raw performance, I once read that getenv() ourperforms $_SERVER -- but the values they return should be the same.