Jump to content

How is best way to track page views in a forum?


johnsmith153

Recommended Posts

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"

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).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.