Log in

View Full Version : Find out what site a visitor cam from



Qopzeep
12-07-2007, 05:47 PM
Hello,

I have seen a script somewhere that enables you to see from which site a visitor came from before he went to yours.

For instance, if user X came from www.google.com to www.<mysitehere>.com and I had the script implemented, I could see that user X came from google.com.

I'm very badly trying to find this script and am unsuccesful so far, so any tips or links would be wonderful!

Thanks,
Qopzeep

djr33
12-07-2007, 10:46 PM
Using a server side script the referrer can be displayed or recorded to a database, etc, but it isn't necessarily accurate-- since this is up to the browser/user, it can be faked or not sent at all. It is generally accurate, though, on average, for statistics, etc.

In PHP, you can find this value as part of the $_SERVER global array:
echo $_SERVER['HTTP_REFERER'];

JohnRostron
12-10-2007, 02:05 PM
The document has a property document.referrer that is "the url of the link that brought the browser to the current document, if any" (David Flanagan, Javascript: the definitive guide).

This works with the caveats mentioned by dir33 above.

John Rostron