What logic is best to use for counting articles read by the same person over time?

I’m planning on storing the number of times an article / page has been viewed in a database. This is so that I can have a list of “most popular posts / articles” in WordPress.

This was a good thread for similar question: How “View Count” is best implemented?

Read More

My question is: A person may view an article multiple times on the same day / week.

What is the industry best practice for counting the number of times an article is read by the same person?

And is there a way to solve multiple users being behind same IP Address?

Update

I’m not after the coding techniques for counting article / post viewes (session, cookies IP address, CGI etc).

I’m just wondering what logic is best to use for counting articles read by the same person over time?

Related posts

Leave a Reply

3 comments

  1. For anonymous viewing, you can associate an IP address with an individual. For non-anonymous usage, you can use the credentials of a person to make sure that multiple viewings of the same page by the same credentials (i.e., individual) do not result in multiple increments to your view counts.

  2. This can be a really complex problem to solve depending on what you are trying to do. I would suggest fist looking at google analytics or piwik which is some php application you install and use like google analytics.

    If you need an in house solution then most likely you have to leverage cookies. There are two types of cookies. A simple cookie can be dropped when user is on page foo.com and the application is trying to set a cookie on foo.com. Another type of cookie is when you are viewing foo.com but another application is trying to create a cookie for bar.com. This is called a 3rd party cookie which sometimes is blocked. This is how services like google analytics track users.

    There are other ways to find unique users. You can use ip address, browser signature, etc… The problem with these solutions are that many companies, universities, or other large companies are usually behind one ip address. You don’t want to count a whole department as one person.

    There other ways you can track users but these are advanced. (localStorage, flash, cache).

    I would advise to use Google Analytics first. If this is not enough then you can pursue other options.

  3. I recommend grabbing all the CGI environment variables like: these from the visitor, parsing them and adding them to a database. This will provide you with a better idea of return visitors.