Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is most accurate method to count total number of distinct real people that have seen a web page? (not number of times that a page is requested). In other word what is your idea to make counting it a little more accurate?

What combination of IPs, cookies, or authentication info may be used for this purpose? How we can maintain related data in DB effectively?

share|improve this question
How many people at the same IP address in the same family do you estimate visit your website? – Kenzo Nov 2 '12 at 19:25

There is no single "correct" method of accomplishing this task. Let me explain why.

Within a single IP many PC may reside behind the NAT. Within a PC user may use different browsers. Withing each browser user can reset it's history (or simply clear cookies).

From other side user can have multiple devices that will create multiple IP addresses for a single user.

In such way a single human can have many user accounts and multitude of historical sessions (i.e. periods of time when neither cookies not environment were not reset).

The most appropriate way counting users is assigning each "clear" session (which has no tracking cookie set) new cookie with a unique ID, which is written back to DB. Upon multitude of criteria IDs are merged.

You can merge two IDs when:

  • user logged in your system (assuming each person has its private credentials).
  • you suspect very intense cookie reset, i.e. spam attack, maybe via Maching Learning
  • there is any other action sequence that connects those IDs

In terms of schema, you may use four tables: hits (*-1) sessions (*-1) people (1?-1) users.

Each hit just connects the visited page and tracking ID in time.

Each session is uniquely described with tracking ID and contains browser and client data (UA, IP etc) and (possibly) foreign key to people row.

Each row of people table represents "unique" visitor. If it's registered, it has one-to-one FK to users table.

However, it might be much better to use log processing tool or write stats to MongoDB collection in order to handle big load.

P.S. If you really need to count exact number of hits, like in serious voting system, you might require SMS two-factor authorization with one-time prior identity verification (like dummy credit card hold) each time the historical session is reset. But something tells me that's an overkill for you.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.