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 destinationip = _SERVER[‘REMOTE_ADDR’]; // gathers IP address of userrefer = _SERVER[‘HTTP_REFERER’]; // gathers referring page of user – good to see where clicks are coming fromtimestamp = date(“Y-m-d H:i:s”, time()); // timestamp
filedate = date(“Ymd”, time()); // creates file-friendly date format for logfile = “filedate-clicklog.csv”; // the log file namehandle = fopen(file, “a”); // open the file in write modestream = “ip,refer,timestamp\n”;
handle, stream);

// now redirect the user!

Subscribe to My Free Weekly Newsletter

Subscribe to My Free Weekly Newsletter

Sign up now to the free Almost Timely Newsletter, released every weekend with the latest news about marketing, technology, analytics, data science, and AI.

  • This field is for validation purposes and should be left unchanged.

You have successfully subscribed to the Almost Timely Newsletter!