A download counter not only provides you useful metrics but also gives your visitors a hint about the most popular files.
If you offer your visitors files to download you may want to count how many times each file is download. I use CCounter, a PHP Click Counter to count the number of times my books have been read. It’s so simple but yet it does everything you need. It’s currently on version 2.0 and its user interface looks a lot better than the original – and the installation is easier too. This “plugin” transforms your files’ URL into a special URL. When a visitor opens that special URL, CCounter counts a view and then redirects the file’s real location. Afterwards, using PHP, you can display the number of types that file was downloaded or viewed.
Install
- Download CCounter 2.0 from the official website at phpjunkyard.com. Unzip the file to a folder named, for example,
downloadmanager
. - Upload the folder to your website via FTP or similar. I used Filezilla and uploaded the folder to
/assets/downloadmanager
. - Use your browser to open the folder you just uploaded. In the example, go to
www.your-domain.com/assets/downloadmanager
. - Follow the installation steps that appear. Don’t forget to delete the folder named
install
.
Configure
To set up a counter for a specific file:
- Upload your file to your website and copy the url, for example:
www.your-domain.com/files/awesome-file.zip
- Go to CCounter’s admin console by visiting its main folder on the browser. Following the example, open the URL
www.your-domain.com/assets/downloadmanager
and login. - Open the New link page and submit your chosen link as a new link. Paste the URL of your file.
- After the URL is submitted, a special tracking URL is generated by CCount, for example
www.your-domain.com/ccount/click.php?id=123
.
Use it
Every time you want to provide a link to your file (<a href="...">
) use the URL generated by CCount (e.g. www.your-domain.com/ccount/click.php?id=123
). When a visitor clicks that URL, CCount will count the click and redirect the visitor to where the real file is (e.g. http://mydomain.com/files/myFile.zip
).
Display it
To show the number of clicks or downloads of a file you need to:
- Place the following code inside the
<head>
tag of the webpage where you want to display count statistics:<script src="https://www.diogonunes.com/assets/downloadmanager/display.php"></script>
- Paste the next snippet exactly where you want the count to appear:
<script>ccount_display('LINK_ID')</script>
, e.g.<script>ccount_display('123')</script>
Simple, but effective!