PHP Click Counter Database: Generate links and keep track of clicks on them

Recommend this page to a friend!
  Info   Example   View files (12)   Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
68%Total: 302 This week: 2All time: 7,280 This week: 121
Version License PHP version Categories
click-counter 1.0MIT/X Consortium ...5.0HTML, PHP 5, User Management
Description Author

This class can generate links and keep track of clicks on them.

It can take the URL of a given link and returns another URL that will be used to keep track of the clicks on that link.

The link points to a script that will be used to record the clicks on a database accessed via PDO, and then it redirects the browser to the original link.

Alternatively the class can also store the clicked links of text files.

The database connection string, the URL for invalid links, the destination link base URL, the file for storing click counts are some of the configurable parameters.


Looking for good pluggable click tracker mechanism
Would like to track how many times various buttons are clicked

Picture of Ettore Moretti
  Performance   Level  
Name: Ettore Moretti is available for providing paid consulting. Contact Ettore Moretti .
Classes: 12 packages by
Country: Italy Italy
Age: ???
All time rank: 111542 in Italy Italy
Week rank: 135 7 in Italy Italy
Innovation award
Innovation award
Nominee: 3x



ClickCounter is a PHP class that allows you to control the number of visitors who clicked on certain links. Useful for statistics on navigation and \ or downloading files.

How use it

To use the class will need, call the static method getHref class CCounter, passing as the only argument the link Example:

If the link is unreachable, the class will direct the browser to the 404 page indicated in configurations. 
File Role Description
core (3 files)
install (1 file)
404.php Aux. Auxiliary script
index.php Example Example script
LICENSE Lic. License text
link1.html Data Auxiliary data
link2.html Data Auxiliary data
link3.html Data Auxiliary data
link4.html Data Auxiliary data Doc. Documentation

  Files  /  core  
File Role Description
   CCounter.class.php Class Class source
   CCounter.config.php Conf. Configuration script
   CCounter.hrefPointer.php Aux. Auxiliary script

  Files  /  install  
File Role Description
   tableCreate.sql Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
This week:2
All time:7,280
This week:121
User Ratings User Comments (1)
 All time
This is a very good and useful class ;-)
4 years ago (Josť Filipe Lopes Santos)

For more information send a message to info at phpclasses dot org.