Skip to main content
Inspiring
July 6, 2007
Question

Statistics / Tracking

  • July 6, 2007
  • 2 replies
  • 337 views
I am working on a project right now where I want to write a small statistics / tracking component. I have an idea about how I want to do it, but I figured I would throw it out there and gather advise first so that I don't end up rewriting it in the end... It is for a Content Management System project I am working on....

Basically I want to track sessions, their user if they authenticate, and what pages they look at so for both security and also for knowledge of how the site is being used for improvement as well as like a most popular page list and such...

I am currently using 3 different tables to accomplish this... instances (tracks application start and stop), sessions (tracks sessions and their associated info), requests (information about a request).

My main question is should I use an SQL statement to get the say top 5 pages based off of the records in the requests table or should I add a field to my pages table called say "hitCount" and then get that info from the pages table. I know that pages would be faster because it will have no where near the records of requests... but on the other hand there would then be twice as many SQL calls when a page is called because instead of just adding the record to requests, now it has to update hitCount in pages...

Has anyone else done this before? I am just looking for ideas, suggestions, advice, and such... and I always am able to find plenty of that here! Thanks for any and all help!

Josh Eby
    This topic has been closed for replies.

    2 replies

    tclaremont
    Inspiring
    July 6, 2007
    I use an autonumber field for my hitcounter (SQL 2k5). I track the username, the page visited, and the date/Time, as well as the IP Address of the machine they are coming from. My OnRequestEnd template inserts the activity on each page request.

    To find the most popular pages, I just select distinct PageViewed and Count(PageViewed). I save this as a CFM page and look at it whenever I want to see stats on each page.
    Inspiring
    July 6, 2007
    Depending on how current your data has to be, you could always store the hit count in your pages table and update it every day/hour/month/whatever.