Just as $_GET and $_POST are reserved name variables used by HTTP, and sent by HTTP?

There are several $_SERVER fields, that can be saved and read later for your traffic analysis.

Three common are $_SERVER['HTTP_REFERER'], $_SERVER['QUERY_STRING'], and $_SERVER["REMOTE_ADDR"], as well as $_SERVER['PHP_SELF'], which is the name of the web page itself!

I use these 10 lines of PHP, to save to a text file, individual customer hits received by (each of) my pages:

$date=date("YmdHis"); <= 4-digit Year, month, day, 24-hour, min, sec 20131031175500
$ref = $_SERVER['HTTP_REFERER']; <= what web page URL sent the traffic!!
$qry = $_SERVER['QUERY_STRING'];
$ThisPage=$_SERVER['PHP_SELF'];
$Users_IP_address = $_SERVER["REMOTE_ADDR"];
$Users_Browser = $_SERVER["HTTP_USER_AGENT"]; <= Bots usually have the word 'bot' in them
$fp = fopen('ips.txt', 'a');
$FWwritethis = $date.', '. $ThisPage.', '.$Users_IP_address.', '.$ref.', '.$qry.'^ '.$Users_Browser.PHP_EOL;
fwrite($fp, $FWwritethis);
fclose($fp);


In the "fopen('0ip.txt', 'a')" statement, the 'a' means "append". So the text file created becomes like a calculator paper-tape record of all web traffic data from all hits to your page(s)! You can save all data from all pages to one file, or individual pages to specific file names.

When the file gets big, manually rename it (like add today's date to it). If fopen() doesn't find the file (in this case 'ips.txt'), it makes a new one on its own! And starts anew!

During your testing, you can put in: print_r($_HTTP,true) and print_r($_SERVER,true) and look at ALL of the $_HTTP and $_SERVER fields your pages are being sent, by the web browser and ISP of your customer(s).

if you find some $_HTTP and $_SERVER variables you would like to save and analyze later, you can add them to the "$FWwritethis =" statement above. I comma-sepperated the variables in my example. You can delimit using characters of your choice, but commas are quite common. As are pipes '|'. Don't use any common keyboard characters, or you will have a headache.

(Check the user reference manual for the flavor and age of LINUX, and especially ASP, your page(s) run on, for exact names and spellings. names have evolved over time.)


A couple of months ago, when a character came on here using a variation of my screen name, the above 10 lines of code (plus the "screen name" variable) could have been added to any footer script, and the "ips.txt' file could have been looked at to spot a individual coming on here under multiple screen names.

It is now almost 2014. These fields, these techniques, have been in use for 10, 15, even 20 years by companies making more money than all of us put together, selling services like traffic analysis and affiliate tracking. That's all well and good, but you can also do it yourself, to compare.

Like how much of your traffic that you are paying to Ad services to send to you - is bots!