This script counts a number of clicks of outbound links. It is a modified version of James Caws's PHP script. To use the script you don't have to modify outbound links - more details can be found at his page. I made the following modifications:
Instead of PHP PEAR DB, my script uses PDO (PHP Data Object). More info: http://www.php.net/pdo
Instead of MySQL database (DB), my script uses SQLite
If tables don't exist, they are created
Number of clicks is stored in additional column in DB
Log creation can be switched off
I created additional script "ccounter/admin/index.php" which displays data stored in DB
Installation
Download the "ccounter.zip" file, unpack it, and copy extracted files to appropriate directory
Edit the "ccounter/tracker.js" JS script and configure it as James Caws wrote
Edit the following PHP scripts: "ccounter/logger.php" and "ccounter/admin/index.php", and configure them, i.e., find and modify the value of two variables:
DBname
It contains the filename (plus a path) of the SQLite database. Remember that the file (DB) and the directory it is in, have to be writable by the web server
Log
0 means "Log shouldn't be created", 1 means "Log should be created". This variable is contained in the "ccounter/logger.php" file only
The last step - citation from James Caws's page:
The JavaScript should be included at the end of your pages that you want to monitor the click throughs of. If you have a general ‘footer’ template, this should be easy. Whatever your scenario, ensure the include is just before the
For security reasons you DB shouldn't be accessible from the web, i.e. keep the SQLite always out of the htdocs. You should also protect the "ccounter/admin/index.php", e.g. make the http://www.yourpage.com/ccounter/admin/ page protected by password - see Apache HTTP Server Version 2.2 Documentation.
it requires PHP 5.1 (or higher)
Document last modified: Tuesday, 09-Dec-2008 12:52:30 CET