2eNetWorX :: Development Community with Tutorial, Script, Code, Programming sections for Visual Basic, Active Server Pages and .Net Framework Developers.  

Simple Statistics, Statisticus :: Article - 2eNetWorX


This article focuses on basic statistical analysis methods and the techniques to implement them into the web pages.

 
  2eNetWorX :: ASP, VB, Asp.Net, Vb.Net, C#, dotNet, .Net OpenSource Projects
MyDev What's New | Projects | Tutorials & Articles | Services | Stats | Contact Us
Guest-09136    /dev :: home :: articles :: statisticus - part #3  85 online visitors
Popular Projects

  • TableEditor
  • StatCounteX
  • 2eNetWorX/Dev
  • MiniSurvey
  • OpenForum
  • PowerTool
  • ShopEZ
  • Trans-It
  • HiLiteR
  • (View All Projects)


    Top 10

    » Contributions


    Tutorials & Articles

    » Recordset Cache
    » OpenSource
    » Statisticus
    » OpenCYA!


    Code Samples

    » Undocumented...
    » Ask For Login
    » DSN'less Connection
    » Who's Online?
    » (All Samples)


    Link Back



    Site Banner


  • Statisticus, Why and How?
    Part III - Simple Statistics

    by Hakan Eskici

    3. Simple Statistics

    In the previous part, we described what we want to learn; pageviews, visitors and averages.

    For pageviews and unique visitors, the idea is simple; get the totals. Depending on the criteria, we may filter our data.

    Now, let's build a database structure to store our data.

    At first, we begin with a single table called "Stats":

    Field Name Field Type
    StatID Long, AutoIncrement, Primary Key
    Date Date/Time
    Time Date/Time
    Path String
    IP String


    With such a table structure, we will be able to learn "PageView and "Visitor" statistics. Here is the code using the "Stats" table to store the data;

    <%
    (...)

    'Get the data into variables first
    sPath = Request.ServerVariables("script_name")
    sIP = Request.ServerVariables("remote_addr")

    'Assuming we have an open connection and our recordset is rs;
    sSQL = "SELECT * FROM Stats"
    rs.Open,,, adCmdTable
    rs.AddNew
    rs("Date") = Date
    rs("Time") = Time
    rs("Path") = sPath
    rs("IP") = sIP
    rs.Update

    (...)
    %>

    After we got the data in our table, it's time to analyse it and generate reports.

    By executing the following SQL statements, we will get the PageView and Visitor information.

    Total Page Views

    SELECT COUNT(StatID) AS Total FROM Stats

    Page Views for a Specific Page

    SELECT COUNT(StatID) AS Total FROM Stats WHERE Path = '/index.asp'

    Page Views Grouped by Pages

    SELECT Path, COUNT(StatID) AS Total FROM Stats GROUP BY Path

    Page views for a specific time period

    SELECT COUNT(StatID) AS Total FROM Stats WHERE Date BETWEEN #mm/dd/yyyy# AND #mm/dd/yyyy#

    Visitors for a Specific Page

    SELECT COUNT(IP) AS Total FROM Stats WHERE Page = '/index.asp'

    Visitors for each Page

    SELECT Path, COUNT(IP) AS Total FROM Stats GROUP BY Path

    Visitors for a specific time period

    SELECT COUNT(IP) AS Total FROM Stats WHERE Date BETWEEN #mm/dd/yyyy# AND #mm/dd/yyyy#

    Visitors for each page for a specific time period

    SELECT Path, COUNT(IP) AS Total FROM Stats WHERE Date BETWEEN #mm/dd/yyyy# AND #mm/dd/yyyy# GROUP BY Path

    Now we are able to get some basic statistics for our pages, we will use these SQL statements later for time domain reports; grouped by day, week, month and even hour. Before this, let's add some more data fields to our table such as Browser, Operating System, Color Depth, Screen Resolution and Referer.

    We will need to use client-side scripting to capture some data using JavaScript which is supported by most browsers. Then we will learn a common way of executing an external ASP page with some parameters.

    We will capture some more data in fourth part of the article.

    Part I - Introduction
    Part II - Measurement Tools
    Part III - Simple Statistics
    Part IV - Adding More Fields
    Part V - Data Normalization Part VI - Data Gets Valuable




    Who's Online

     Bot: Msn
     Bot: Google
     (43) guests
     (40) repeated

    How is this done?


    Popular Web Sites

      FogBugz Hosting Plans
      SubVersion Hosting Plans
      SourceGear Vault
      Hosting Plans

      Note Thing - A Perfect
      To-Do List Software
      .net Localization
      components from SWBOX

      Mary Kay Products

    Admin's Toolbox

    Web Database Management
    Web Site Statistics
    Survey Manager
    Integrated forum for webpages
    OpenSource WebSite Framework


      privacy policy , license , disclaimer , © 2000-2004, 2eNetWorX.   [page generated in 31 ms.]