www.mithril.ca

PHP Code Samples :: Site Statistics and Usage Tracking Script

Web-Based Apps
phpClassifieds Demo
MP3 Database Search
MP3 Search Engine
Search Engine
Mithril Web Mail
Photo Gallery
Code Samples
PHP
    - DB Abstraction Layer
    - Site Usage Tracker
    - MP3 Database Search
    - MP3 Search Engine
    - Search Engine
    - Employee's Section
    - phpClassifieds Demo
PHP-GTK
    - mediaCat-GTK v2.0.8
Visual Basic
more info.....
Links of Interest
php.net
gtk.php-net
OSDN.org
SourceForge.net
Corrado Club of Canada
The Onion
more links...
Personal Info.
About Geoff A. Virgo
View my Resume
Site Statistics
Contact the Sys. Admin
This library is a combination of my Hit Counter and Stats Tracker scripts.  Since the two did much the same thing, when I re-wrote this site's backend, they were combined into one set of classes.  The base usage class extends the Database Abstraction Layer Class and does both the hit count and usage tracking as well as displaying the hit count.  The class used to display the usage stats extends the base usage class, allowing it to perform all functions.  Since this library is class based, it has access to it's own dedicated database connection(for the length of the script run) minimizing the impact on the rest the site which needs database access.  Both the hit counter and stats tracker use cookies to store a unique identifier, an 11 digit number created by PHP's random number generator, to allow the tracking of return visits.  Because it is called from the includes folder this library can track hits on every page of your site and display the hit count where ever you choose.  I personally think this is a big improvement over many of the "free" CGI or JavaScript based counters which can only track the pages displaying the ad button those companies provide.

Features:

    Hit Counter
    • can be configured to increment on every page load, or only on the initial page load in a user session

    Stats Tracking
    • users are identified by an 11 digit number which is randomly generated and stored on the browser using a cookie
    • stats for external navigation into your site records:
      • the user's ip
      • browser type
      • date/time of first and last visits
      • number of visits
      • point of entry
      • referring url
      • search engine
      • search query keywords
    • external navigation stats can be viewed either in raw html or graphical (if your PHP installation has GD with PNG support) mode
    • the graphs are created by month and stored on the server to reduce server load
    • graphs for the current month are re-created for every request ensuring the most recent data is represented
    • sample graphs can be viewed here
    • internal navigation stores:
      • the requested file
      • the address within your site from which it was requested
      • the date/time of the request
      • the user's 11 digit identifier is not used for internal navigation tracking

    Search Engines
    • search engine referral stats displays:
      • keywords used
      • number of times that keyword combination was used
      • last date/time the keyword combo was used
      • a link to the search query on the referring engine allowing you to determine what other sites show up for the same search
    • stats are broken down by search engine
    • you can specify 2 query identifiers per engine to allow for more flexibility
    • public statistic's displays:
      • the current date/time on your server
      • your server software, PHP, and MySQL version
      • total number of hits
      • rough percentages of browser usage (IE 4+, Netscape 4+, and other)

  • admin browsers can be removed from both hit count and stats tracking to give more accurate results
  • admin section allows for full manipulation of the app's behaviour and appearance (table and image colour schemes)
  • default colour schemes for both tables and images can be overridden on a per script basis using the appropriate set() methods
  • database records can be searched for new referring search engines, and common non-engine url's/ip's can be blocked from showing up in this search
  • full API documentation (in the JavaDoc style) is included in the download package

The following links will allow you to either view or download the source code.  If you find my script useful, please sign my guestbook or link to my page.

View the script's source codeDownload the script


Page generation: 0.063035 sec