DISQUS

Newest Industry: Hit Tracking with PHP and MySQL

  • Karthik · 7 months ago
    Why do you convert the IP using ip2long - are there any benefits to it?
  • Stephen Pierzchala · 7 months ago
    Using ip2long is a holdover from my Geographic IP Database, where performing IP searches was far easier with a numeric value than an IP address. Most application development languages have a way to convert these numbers back to IPs quickly. As well, this conversion can occur natively in MySQL SELECT statements.

    You could add a column to the database table that added the raw IP address with very little change to the method described in this article.
  • Chris · 7 months ago
    What about scalability issues? The database size will expand quickly with traffic and it adds another hit on the server with each page load.
  • Stephen Pierzchala · 7 months ago
    This is definitely a solution for a small web site, and was designed to be small and light.

    I started using this more when I was hosting my blog outside of the tracking infrastructure, so there is no increase in traffic on either infrastructure.

    Steps could also be taken to aggregate the data based on patterns in the data and then archive the raw results outside the DB.

    Many ways this can be improved upon. But it gets folks thinking.