Getting Website Hit Stats

As easy as it is to plug in Googles Analytics JS code into the base of your website, you still wont get a good idea of what spiders are crawling your site, and how often, as well as a few other limitations / omitted abilities.

That is a simple way to use your own custom code to log what’s happening on your site. No fancy graphs here. The fact that it’s completely server-side cleans up the front end code and simplifies the loading of said HTML, with no external references on each page load. Sending it to a database would be one of the first desirable improvements.

NOTE: Be wary of using a single log file that isn’t purged, its fine for a few lines, but once it reaches a few thousand PHP needs to cycle right through it which drastically reduces performance, and pageload.

The following line creates a new file each day, which depending on how many pageloads are expected, should be fine…

$myFile =  "hide_melogs/".date(dMy).".txt";

Leave a Reply