Skip to content Skip to sidebar Skip to footer

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

Solution 1:

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

<ahref="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.

Solution 2:

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.

Post a Comment for "Http_referer Blank, Need Alternative"