ASP: Active Sessions, Active Logins and Total Site Hits - Problem Solved (Page 2 of 5 )
Sure you can paste this tracker component on every page on your site, but that would be highly cumbersome, inefficient and inaccurate as that would be lots of double-counting. You also cannot keep track of the active sessions on your site which means the number of visitors to your site at any moment. Moreover, once you update your page, or when the server shuts-down for maintenance, you lose all data and history of your hit counts.
I am sure there are components out there that can do the job but it all depends on the price and whether your remote web administrator allows you to install these components on your virtual server (sharing the server with many websites).
There is a simple and free way to do what is described above via Microsoft Active Server Pages (ASP) which is widely used and implemented and free. Most websites, whether they are running IIS or Apache, support ASP.
All you need to do is to upload this script on this page to your server and you will be able to see a fairly accurate count of hits on your site, not just the page alone. The scripts provided below MUST be pasted on a text-based file called GLOBAL.ASA.
This file is always read by the server first whenever a browser requests HTTP content from the web server and its therefore accurate as any pages requested by the server will go through the GLOBAL.ASA file first.
The GLOBAL.ASA file is a fairly narrow topic but I will only highlight the 4 events that the GLOBAL.ASA file implements. You can also declare application-wide objects and variables on this file but we will only focus on keeping track of site-hits here.
The events that the GLOBAL.ASA file implements corresponds to the Application and Session Object. They are namely Application_OnStart, Session_OnStart, Session_OnEnd and Application_OnEnd. They are all run in that order.
Application objects are used throughout the application regardless of the users and are started when the web-server starts and ends when the web-server shuts down (or when you copy a newer version of the GLOBAL.ASA file onto it). Session objects, on the other hand, are used per browser session. This means that a new browser, regardless of where it comes from, instantiates a new session. Session objects are cleared and re-initialized when the session times out which in most cases is 10 minutes.