PHP Classes

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

Recommend this page to a friend!
  Info   View files Example   View files View files (12)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 68%Total: 361 This week: 1All time: 6,896 This week: 560Up
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.

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: 107741 in Italy Italy
Week rank: 411 Up18 in Italy Italy Up
Innovation award
Innovation award
Nominee: 3x

Recommendations

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

Example

<?php
require_once 'core/CCounter.class.php';
$CC=new CCounter();
?>
<html>
<head>
<title>Click Counter Example</title>
</head>

<body>

<h1>Click Counter PHP - Example use</h1>
<p>Click a link to increase the relative counter.</p>

<a href="<?php print_r($CC::getHref('link1.html')); ?>" target="_blank">Link1</a><br/>
<a href="<?php print_r($CC::getHref('link2.html')); ?>" target="_blank">Link2</a><br/>
<a href="<?php print_r($CC::getHref('link3.html')); ?>" target="_blank">Link3</a><br/>
<a href="<?php print_r($CC::getHref('link4.html')); ?>" target="_blank">Link4</a><br/>
<a href="<?php print_r($CC::getHref('link5.html')); ?>" target="_blank">Link5</a> (404 page, link broken example)
</body>
</html>


Details

ClickCounter

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. 

  Files folder image Files  
File Role Description
Files folder imagecore (3 files)
Files folder imageinstall (1 file)
Accessible without login Plain text file 404.php Aux. Auxiliary script
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file link1.html Data Auxiliary data
Accessible without login Plain text file link2.html Data Auxiliary data
Accessible without login Plain text file link3.html Data Auxiliary data
Accessible without login Plain text file link4.html Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  core  
File Role Description
  Plain text file CCounter.class.php Class Class source
  Accessible without login Plain text file CCounter.config.php Conf. Configuration script
  Accessible without login Plain text file CCounter.hrefPointer.php Aux. Auxiliary script

  Files folder image Files  /  install  
File Role Description
  Accessible without login Plain text file tableCreate.sql Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:361
This week:1
All time:6,896
This week:560Up
User Ratings User Comments (1)
 All time
Utility:83%StarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:83%StarStarStarStarStar
Examples:91%StarStarStarStarStar
Tests:-
Videos:-
Overall:68%StarStarStarStar
Rank:416
 
This is a very good and useful class ;-)
8 years ago (José Filipe Lopes Santos)
80%StarStarStarStarStar