johnsmith153 Posted September 7, 2009 Share Posted September 7, 2009 I also need to ensure if a person just keeps refreshing the page that it won't keep incrementing number of views. Your answer may be somthing like: "Just add a record to a table wheh view, then search table when need to find total number of views - ensuring only add unique record by IP for that topic" Quote Link to comment https://forums.phpfreaks.com/topic/173456-how-is-best-way-to-track-page-views-in-a-forum/ Share on other sites More sharing options...
bundyxc Posted September 7, 2009 Share Posted September 7, 2009 I think that you just answered your own question. Quote Link to comment https://forums.phpfreaks.com/topic/173456-how-is-best-way-to-track-page-views-in-a-forum/#findComment-914342 Share on other sites More sharing options...
johnsmith153 Posted September 7, 2009 Author Share Posted September 7, 2009 The trouble is if I store all in one table then eventually I will have millions of records, which is too many for a table needing searching as often as this will. Quote Link to comment https://forums.phpfreaks.com/topic/173456-how-is-best-way-to-track-page-views-in-a-forum/#findComment-914344 Share on other sites More sharing options...
bundyxc Posted September 7, 2009 Share Posted September 7, 2009 Are you looking for pageviews, or for visits? If you're looking for pageviews, then you'll probably have to accept that a dumb user will be able to do that (unless you want to try to code a script measuring the times between refreshes, and recognizing if it's malicious or not). If you're looking for website visits, I'd do something like this: check to see if IP address is found in database; if IP is not found in database { insert into database with current time and IP; add one to counter; } Then, every hour or so, run a query deleting all visits more than a day old. (Probably using cron jobs). Quote Link to comment https://forums.phpfreaks.com/topic/173456-how-is-best-way-to-track-page-views-in-a-forum/#findComment-914349 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.