Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP_REFERER blank, need alternative

I have a simple signup form that needs to track number of hits from one specific external referer. This is a simple task with PHP's:

$_SERVER['HTTP_REFERER']

however, it is blank. After doing some research i tried to use some javascript:

document.referrer

Still blank. :(

I really dont need anything elaborate, but am trying to NOT use awstats.
Is there any other way to get the referer (hacks accepted)?? Or am I stuck with the stats???

-thanks

like image 710
lmno Avatar asked Jun 07 '11 16:06

lmno


2 Answers

In short: If the user don't want it, you will never know, where he comes from. However, a more "reliable" solution may be to add the referrer to the link from the origin site to yours. Something like

<a href="http://example.com/index.php?referrer=originId">Visit example.com</a>

This requires, that external sites cannot just link to your site, but always needs to add their personal id. If this is not possible there is not much you can do.

At all its possible, that someone may change this id too.

like image 165
KingCrunch Avatar answered Oct 01 '22 07:10

KingCrunch


The referer is possibly sent in the HTTP request's header.

It is possible that the browser will not even send it, or some kind of proxy, firewall or security suite strips it out or even changes it. You cannot rely on it.

There is only one thing you can do: if it is empty, consider that you don't know the referer.

like image 43
kapa Avatar answered Oct 01 '22 08:10

kapa