Installation:

1. Open admin/init.php file and edit "Config" section:

   $ct_host      = "MySQL_hostname_(usually_localhost)";
   $ct_username  = "MySQL_user's_username";
   $ct_password  = "MySQL_user's_password";
   $ct_database  = "MySQL_database_name";
   $ct_table     = "MySQL_table_name";
   $ct_replace   =  true_or_false;
   $ct_days_keep =  number_of_days_to_keep_statistics;

2. Upload files to the server.

3. Open admin/setup.php script in your browser to create MySQL table.

4. To test the script, open sample.php script in your browser and click sample links therein.

5. To view statistics, open admin/index.php script in your browser.

6. Place the following code in the header section (between tags <head>
   and </head>) of your site:

   <script type="text/javascript">
   var clicktracker_url        = "http://www.yourdomain.com/path_to_click_tracker/click-tracker.php";
   var clicktracker_domains    =  Array("", "yourdomain.com", "www.yourdomain.com");
   var clicktracker_extensions =  Array("doc", "exe", "rar", "zip");
   </script>

   <script type="text/javascript" src="http://www.yourdomain.com/path_to_click_tracker/click-tracker.js"></script>

   The script will track clicks on the links:
   (a) to all domains other than those specified in clicktracker_domains variable;
   (b) to all files with extensions specified in clicktracker_extensions variable.

   This way you can track:
   (a) external (outbound) links;
   (b) download links.

7. Password-protect admin directory

If you have any difficulties installing the script, feel free to contact me.

If you find this script useful, consider placing the link to the homepage of this script
http://www.php-development.ru/php-scripts/click-tracker.php
somewhere on your site.

Ilya S. Lyubinskiy
http://www.php-development.ru/