Site Hits Log Sample

      

This sample tracks each hit to an ASP page and logs information about the user viewing the page. The IP address, the path of the page being viewed, and the client browser are all stored in the Counter table in the Gallery database. These values are stored to allow reports to be run to see the activity of a page.

Behind the Scenes

This samples uses one file: Counter.asp. This file uses the Recordset design-time control to create a connection to the Counter table in the Gallery database. After the recordset is open, a new record is added to the table and data is written into the appropriate fields:

function CounterRecordset_ondatasetcomplete(){
      CounterRecordset.addImmediate();
      CounterRecordset.fields.setValue("Remote_Host", Request.ServerVariables("Remote_Addr"));
      CounterRecordset.fields.setValue("Path_Info", Request.ServerVariables("Path_Info"));
      CounterRecordset.fields.setValue("HTTP_User_Agent", Request.ServerVariables("HTTP_User_Agent"));
      CounterRecordset.updateRecord();
   }

Using a Label design-time control, the total number of records from the recordset is used to display the current count of hits to this page.