Someone reminded me recently that I haven’t posted the click tracking software I mentioned during PodCamp Toronto. This is it – to use it, edit the URL at the top of the code, then copy and paste it into its own directory on your server, naming the file index.php. Next, link to that directory – for example, and it will automatically record a few statistics and then bounce the user invisibly to the destination you want them to go to.

The statistics it collects are:

  • IP address
  • Date
  • Time
  • Referring URL

No personally identifying information is collected, unless for some reason you mapped your static IP address to your personal domain, in which case, you probably want people to know that anyway. The stats themselves will be in a text CSV file stored in that same folder, broken out by day. It collects raw clicks, so if someone comes and visits you over and over again, it’ll record it each time.

Here’s the code:


$url=””; //change to end destination

$ip = $_SERVER[‘REMOTE_ADDR’]; // gathers IP address of user
$refer = $_SERVER[‘HTTP_REFERER’]; // gathers referring page of user – good to see where clicks are coming from
$timestamp = date(“Y-m-d H:i:s”, time()); // timestamp
$filedate = date(“Ymd”, time()); // creates file-friendly date format for log
$file = “$filedate-clicklog.csv”; // the log file name
$handle = fopen($file, “a”); // open the file in write mode
$stream = “$ip,$refer,$timestamp\n”;
fwrite($handle, $stream);

// now redirect the user!

Pin It on Pinterest

Share This