• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Registering article "reads"

Hey guys, got a project going where users can read and comment on different news articles.

However, I'm a little bit stuck on how best to count the number of times a user has read an article.

For example, the simplest way to record the number of reads is by using a "read_count" field in my "article" table and then incrementing this field every time a user clicks on the link for an article (I would call the increment function just before I load the view).

But it's quite obvious with the above method that I won't get a true representation of the number of reads. Users who refresh their page would induce another increment on the read count.

So I think the best way is doing it so that any reads registered in a 10 minute period count as only 1 read.

I'm thinking I'll need to use the session class and use the session ID's and tie in with the session refresh time.

So finally, I would then need another table in my database called "article_read", which will store information which will be refreshed every 10 minutes, and then every 10 minutes I would use that information to update the read_count field in the article table.

Hmmm, rambling a bit now! Does anyone have experience with this sort of thing?


i think you better make the read time dynamic because you can have articles that only have one or two paragraphs and others that are several long. But the base of your idea seems solid.

Sure, but I'm not sure if that would make too much difference. I don't think it matters how long it takes a person to get through a news article.

I just want it so that if I view the same article once a day, it will count as 7 views after one week.

But if I viewed the article 10 times in 30 minutes it would only count as 3 views, or something like that.

I need it to be able to determine which articles are more popular than others, but I've also got a rating mechanism which requires the number of times an article as been viewed.

maybe you are right but to fine tune your method further in the case of 10 times in 30 minutes the count should be 1 view if the viewing is consecutive. To check if the viewing of the article is consecutive you can check if the article is requested a second time after the first time expired within the reading time you set.

To be more concrete : reading started at 12.00 with a 10 minute reading time, so if the reader reloads the article before 12.20 it's 1 view. If the second time the reader loads the page is 12.12 it's still 1 view if the page is reloaded before 12.32, and so on.

I think with that system the reading time becomes important.

[eluser]GSV Sleeper Service[/eluser]
Quote:But it’s quite obvious with the above method that I won’t get a true representation of the number of reads.

From my experience, the only people that care about page impressions are marketeers, and they couldn't care less if the numbers are slightly inaccurate, they just want to see big numbers, which is probably why lots of sites now split content into multiple pages.

It sounds pretty easy to accomplish...

// TODO - Make sure the browser supports cookie before increasing the counter;

There are two things you would need to know:
1. It's very easy to delete the cookie...
2. If the cookie doesn't exists, make sure the browser supports cookies so we don't increase the counter for browsers that simply don't even support cookies (and make us think like they were never counted).

[eluser]Nick Husher[/eluser]
A log table that tracks referrer and name info would be more useful overall. You could create a hook that would open the database, read in the header information (incoming IP address, name and browser info, and referrer [if any]), then load the article. In this way you could run some more sophisticated data analysis when you figure out what your data actually looks like.

That's way more complex, it sounds like he needs something simple (such a counter).

Nick Husher - That's the way I log whatever I need (IP, referrer, user_agent, etc.), glad to know I'm on the right path! :-)

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.