I want to count the number of visits (or visitors, not page requests or hits) made to my whole site.
I want to store each visit in a database to show some graphics with this data in the future.
Also, I want it to be reliable, fast and not to be polling to database for each page request. So, I think I should put some code in some entry point, but I don’t know where, and not in the Global.asax event AppEndRequest. I’m guessing to code the SessionStart or SessionEnd events.
How can I make this visit counter?
Note that Syed’s suggestion will track the number of visitors, while Jhonny’s will track the page hits. You might want to decide which one you’re after.
Assuming you want visitors, I agree with Syed, catch Session_Start in global and increment a number in the database.
You could get more useful information if you store extra info in the database – for example a table like this:
This would probably be better than just incrementing a counter, because you can check the number of visitors last month or this year, etc. and also get information about time-of-day usage.
However you did ask for the simplest possible way, and a simple counter would accomplish that for sure.