Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET and C# Page View Counter: Using a Database

Tags:

c#

asp.net

I'm a working on a project similar to the concept of stackoverflow.com

There will be lots of questions, and I would like to have a Page View Counter for every question.

I feel that the best way is to use a database, since the number of questions will be big, and it will increase by time.

It would be really easy if I just created a TABLE Question_Views And have a row for each question.

Something like this.

ID-----Question_ID------Views
1-------23--------------400
2-------24--------------301
3-------25--------------123

But does page counters take in consideration the IP Address? means, if I open the webpage of question number 23, and then another day I'll view this question as well, does it increment 1, or 2?

And if I need to take in consideration the IP Address, this approach is kind of wrong right?

like image 215
user1665700 Avatar asked Dec 25 '12 22:12

user1665700


1 Answers

Its sounds easy - but its not if you like an accurate counter.
You have

  • Bots that reads and index your page, both know and unknown
  • Users with disabled cookies, and/or disabled javascript
  • Google and Bing that capture the image from your site for live previou
  • Users that load again and again the page for refresh
  • Users that are behind corporate firewall and have common ips.
  • Users that change ips because they are use dynamic ip connection
  • Attackers that try to manipulate the data.

Just this days YouTube remove billions of false statistics data from the page views!

So the question is now, what are you going to measure ?

  1. Visits ?
  2. Visitors ?
  3. Page Views ?
  4. Unique Page Views ?

The difference between clicks, visits, visitors, pageviews, and unique pageviews are critical on how you going to measure the views.

Also is critical on how you recognize that is a visitor and not a bot, or an attacker that try to manipulate the counter ?

One idea is to keep track of all that parameters, and show the unique page views. One user can count as 1 unique page view, even if is see the page 10 times for the session of cookie that have. When the session expires and the user come again, eg if he come after 60 minute with out session, then you count him again.

And the difficult here is to locate all the bots, and the "false users" that see one page and go.

like image 123
Aristos Avatar answered Oct 21 '22 14:10

Aristos