Difference between revisions of "Click Counter III"

From TNG_Wiki
Jump to navigation Jump to search
Line 252: Line 252:
  
 
This link has been clicked &lt;span color=&quot;#FF0000&quot;&gt;&lt;script&gt;ccount_display(9)&lt;/script&gt;&lt;/span&gt; times<br /><br />
 
This link has been clicked &lt;span color=&quot;#FF0000&quot;&gt;&lt;script&gt;ccount_display(9)&lt;/script&gt;&lt;/span&gt; times<br /><br />
would produce such output: This link has been clicked <span style="color;red">4</font> times.
+
would produce such output: This link has been clicked <span style="color:#FF0000">4</span> times.
  
 
If you get an <b>undefined</b> error instead of a number please double-check the ID number you entered in the code above!
 
If you get an <b>undefined</b> error instead of a number please double-check the ID number you entered in the code above!

Revision as of 19:12, 8 September 2020

Restricted Downloads of Click Counter III are restricted to logged in users. If you do not have a user account on the TNG Wiki use the Request Account link to request a user account Restricted
Caution If you have trouble downloading with Google Chrome, Vivaldi, Brave or other Chromium based browser, try using a right-click and select Open in new Window, then F5, or use another browser such as Firefox


Caution


Click Counter III
Summary Standalone drop-in program
Validation The addon is XHTML compliant.Valid-xhtml10.png
Mod Updated 31 May 2019
Download link
version 3.0
TNG All
Download stats View download statistics
Author(s) Bart 'Roebie' Degryse (no longer online)
Maintained by Rick Bisbee and the TNG Users group
Homepage Click Counter III
Mod Support Support for Click_Counter_III
Contact Developer As above
Latest Mod 3.0
Min TNG V n/a
Max TNG V m/a
Files modified
Related Mods
Notes


Counting sessions.jpg

Program Description

Click Counter is a copyrighted, standalone program written by Bart "Roebie" Degryse to detect and save the number of hits on selected website links. TNG mod developers have used it for years to track the number of times their mods are downloaded. The idea is to prioritize maintenance efforts against those mods that are most widely used.

Sadly, Bart suffered a tragic accident several years ago and no longer has an Internet presence. His original program cannot be downloaded from his now-defunct website anymore.

TNG mod developers began offering mods for Click Counter to add additional features like 1) optionally restrict downloads from the TNGWiki to users logged into their wiki accounts, 2) send email notification to the mod developer when one of their mods is downloaded and 3) optionally include geo-location information about the download.

Bart's Click Counter and these mods have been very popular. However, mods are inherently kludgy -- often axes where scalpels are needed. To repair and maintain them, someone has take the time to study the original Click Counter program, understand how the mod code works and then devote considerable time to get everything running correctly again.

Click Counter III integrates the best of the Click Counter II mods into Bart's original program to make it more efficient, bug-free and maintainable going forward. Click Counter III is independent of TNG -- it can be run without even having TNG installed. TNG upgrades should not require revision to Click Counter III.

Please note that Bart Degryse's copyright still covers all versions of Click Counter, including this one. Take time to read it carefully. Our hope is that Bart recovers from his injuries soon and returns to the TNG community.

Feature List

  • Count all hits or unique hits
  • Works for regular links as well as download links
  • Password protected admin panel
  • Links can be grouped
  • Statistics per group, per link, per selection of groups or per selection of links
  • Inline statistics
  • Graphical display of number of downloads
  • Database can be stored outside the webroot
  • Downloadable files can be stored outside the webroot
  • Downloads can optionally send email notification to mod developer(s) Redcheck.png new
  • Download links can add cc addresses to email notification Redcheck.png new
  • Email configuration file can be stored outside the webroot Redcheck.png new
  • Email can use TNG config.php file for email configuration Redcheck.png new
  • Email notifications can optionally provide geo-location of download Redcheck.png new
  • Extensive documentation
  • Some of the core files can be shared between Click Counter III instances

Requirements

  • A working web server with PHP 5.5 or higher
  • Enough patience to read the manual.

Readme.gif

New Installation

  1. Download the Click Counter III zip file as shown in the summary in the upper right corner of the page.
  2. Extract the 'ccount' folder from the download zip file to your desktop.
  3. Change the name of the folder if you want it named differently.
  4. Inside the folder, click on readme.htm to display the manual in your default browser.
  5. Edit settings.php and enter values applicable to your website. See the table below. You can also consult the installation chapter in the manual on how to do this.
  6. Upload the click count folder to your website where it can be accessed with a URL.
  7. If you already have a Click Counter database (ccount.db) from a previous installation, copy it into this folder.
  8. If your settings are correct, you can start using Click Counter III by navigating your browser to the Click Count folder, for example, https://www.example.com/ccount
  9. If you get errors or a white screen, go back to your settings, read the applicable area of the manual and make sure you have set them correctly.
  10. Read 'Using Click Counter III' and 'Counting downloads' chapters of the manual for how to use it.

Upgrading to Click Counter III

  1. Use your Click Counter Control Panel to save a copy of your database to your desktop or to another safe location.
  2. Uninstall your Mod Manager mods for Click Counter II.
  3. Rename your website's current Click Counter folder to protect its contents.
  4. Follow the Installation instructions above to add a new Click Counter III folder to your website.
  5. Copy your database backup file (ccount.db) to your new Click Count III folder, overwriting the empty file there.
  6. Do not copy your old settings.php file because the new settings may be different and will likely cause errors or a white screen. Instead, open them side by side and copy your old settings values to the new settings.php file.
  7. After Click Counter III is up and running you can delete your old CC II folder if you want.

Tip: If you store your database file (ccount.db) outside your Click Counter III folder, it will be protected from being overwritten in future upgrades. Just be sure to point $settings['database'] to its new location.

Click Counter III Setup Parameters

Setting up Click Counter III is as easy as editing the settings.php file in your Click Counter III folder — 'ccount' if you have not renamed it. Here are the parameters you need to set:

Variable Value
$settings['apass'] Password to use for entry into the Click Counter III admin panel. Initial password is set to 'admin', but it should be changed at your first opportunity.
$settings['apass']="myDogBoo2";
$settings['click_url'] The URL to the Click Counter III click.php file. For example,
$settings['click_url']="https://www.example.com/ccount/click.php";
$settings['click_url']="count.example.com/click.php";
$settings['count_unique'] Count only unique clicks during a period of time set below. A value of 1=YES, 0=NO. To only count unique clicks:
$settings['count_unique']=1;
$settings['unique_hours'] If count_unique is set to "1", the period of time in hours during which to only count multiple downloads as one. If the $settings['count_unique'] is set to "0" all downloads will advance the click counter by one each time. To only count unique clicks with a 24-hour period:
$settings['unique_hours']=24;
$settings['webroot'] Enter the server path to your website root directory, for example:
$settings['webroot']="/home/user/public_html/tng/";
Note the trailing forward slash.

Settings that may be left as they are

$settings['database'] The path to your click counter database (ccount.db). This value is preset; you will only need to change it if you move your database, for example, to a folder outside public access to the website.
$settings['database']="ccount.db";
$settings['accessor'] The path to your click counter database interface. This value is preset; you will only need to change it if you move the interface, for example, to a folder that will be shared with other instances of Click Counter III.
$settings['simpleDBAccessorSQLite.php']="simpleDBAccessorSQLite.php";
$settings['downloadlib'] The path to your click counter download library. This value is preset; you will only need to change it if you move the library, for example, to a folder that will be shared with other instances of Click Counter III.
$settings['downloadlib']="downloadlib.php";

Required for email notifications

$settings['sendmail'] Set this to "1" for email notifications; "0" and no emails will be sent.
$settings['sendmail']=1;
$settings['mailconfig'] Sets the path to your email configuration file for SMTP support. This may not be left empty. You may set a path to your TNG config.php file and Click Counter III will use the SMTP values found there. Click Counter III comes with a mailconfig.php file that you may fill in and use instead.
$settings['mailconfig']="../config.php";
$settings['mailconfig']="/home/user/config.php";
$settings['mailconfig']="mailconfig.php";
$mail_to Set this to the email address(es) you want your notifications to go to. Multiple addresses can be put on one line, separated by commas.
$mail_to="admin@example.com";
$mail_to="downloads@example.com,admin@example2.com";
$mail_from Set this to the email address you want your notifications to come from. $mail_from address is intended primarily for plain PHP mail, but if not left empty, the value here will override the SMTP $mailuser address from the SMTP config file at $settings['mailconfig']. $mail_from should be a valid email address on your website.
$mail_from ="webmaster@example.com";
$settings['ipinfo'] Set this to "1" to include geo-location of download in notifications. If "0", no geo-location information is included.
$settings['ipinfo']=1;
$settings['restricted'] Set this to "1" to require a user id be sent with the download request. TNGWiki uses this to determine if the user is logged into TNGWiki when making the request.

Click Counter III download links can be set to ignore this restriction in the admin panel. So you can restrict all downloads here, but allow some to be downloaded without restriction in the CC III admin panel.

$settings['restricted']=1;

Displaying A Link Count

If you want to display a the count for a specified link inside a statement or some other context on a web page like this -- "This link has been clicked 4 times!" -- there are two ways to do it.

Ajax Method

To display the number of clicks on your web page with the AJAX method follow these two steps:

  1. Add this code in your HTML document HEAD (paste it somewhere between <head> and </head> HTML tags):

    <script src="display.js"></script>
    <script>
      window.onload = MakeRequest(LINK_ID, "TAGID", "PATH_TO_display.php" );
    </script>

    • REPLACE LINK_ID with the ID number of the link you want to display the count for (IDs can be found when you login to the Click Counter III Admin Panel)!

    • Provide an ID for the HTML tag pair where the count is to be inserted, for example inside a
      <span id='TAGID'></span> pair.

    • Finally add the Path to the display.php file in your ccount folder, for example "ccount/display.php". For example:

        window.onload = MakeRequest(13, "TAGID", "ccount/display.php" );

  2. Add an HTML tag pair to the page that will display the number of clicks and give it the same TAGID id as you used in the first step. Typically the SPAN tag is used for this (although some others could do as well) and it is often embedded in other tags like the P tag. Of course this SPAN tag can be styled: <p>This link has been clicked <span id="TAGID" style="color:red;"></span> times.</p>

This would produce such output: This link has been clicked 4 times.

You can use whatever you want to replace TAGID by as long as it is a unique id in your HTML document and you replace TAGID on both places.

Non Ajax Method

As said Click Counter III allows you to display the number of clicks on a link on your website. You don't have to use AJAX however to do so. To display the number of clicks on your web page with the non-AJAX method follow these two steps:

  1. Add this code in your HTML document HEAD (paste it somewhere between <head> and </head> HTML tags):

    <script src="ccount/display.php"></script>

  2. Add this code where you want the number of clicks to appear:

    <script>ccount_display(LINK_ID)</script>

    REPLACE LINK_ID with the ID number of the link you want to display the count for (IDs can be found when you login to the Click Counter III Admin Panel)! To display the number of clicks on the link with ID 13 you would use this code:

    <script>ccount_display(13)</script>

You can add any HTML tags around this code to format the count number. This code for example:

This link has been clicked <span color="#FF0000"><script>ccount_display(9)</script></span> times

would produce such output: This link has been clicked 4 times.

If you get an undefined error instead of a number please double-check the ID number you entered in the code above!

When to use which method? Each time the MakeRequest (see AJAX method) is used your page will send a request to the server, a database connection will be made, the requested number of click will be fetched from the database and the result will be sent back to the browser. When you only display very little number of clicks this overhead is ok. However suppose you have 50 links in Click Counter III and set up a page to show them all you will have this overhead 50 times. On such occasions it's better to use the non AJAX method. This method uses the same 4 steps to get your numbers but it fetches all results at once. So there's no overhead there. But clearly fetching all 50 results if you only need a few of them is also an overhead.

Displaying Number of Clicks - Statistics Method

There is a third method to show the number of clicks: statistics. This method creates a whole new page for you and is thus not suited if you want to show numbers inline like the examples above.

This method on the other hand allows you to show numbers for a single link, several links, one group, several groups or all links. The statistics page is called by placing a regular link on you page the visitor can click on. These 5 examples show you all possibilities:

  • <a href="index.php?action=stats&id=2">Show statistics for the link with id 2</a>
  • <a href="index.php?action=stats&id=2-4-16">Show statistics for the links with id 2, 4 and 16</a>
  • <a href="index.php?action=stats&groupid=3">Show statistics for the group with id 3</a>
  • <a href="index.php?action=stats&groupid=1-6">Show statistics for the groups with id 1 and 6</a>
  • <a href="index.php?action=stats">Show statistics for all links</a>

Using full URLs you can place your statistics links on other domains too, just like you can with any other link. You might want to use the target attribute on this link too:
<a href="https://www.yourdomain.com/ccount/index.php?action=stats&id=2" target="_blank">Show statistics</a>;

Screenshots

Click Counter III screenshot of a group of links This image shows the Compact Person Media group. In this group are the three zip files that have been made available so far. You can see how many times each version has been downloaded, when they were added and what their unique id is. You also see the X, O and E buttons for deleting, reseting and editing each link.
To add a new link you have to provide a name and an url for the link. If you want you can also choose the group from the dropdown list. As you can see there is also extra information on each form field. Click Counter III adding a link
Click Counter III link statistics The Click Counter III admin panel also provides some statistics on the links you've created: their number, the total number of clicks, the avarage per link and the link with the most clicks.
Adding a new group with the Click Counter III admin panel is as easy as can be: just provide a group name. Click Counter III adding a group
Click Counter III group statistics The group statistics list all existing groups, their unique id and the number of links in each group. You also see the X and E buttons for deleting and editing each link.
Click Counter III backup and restore
Click Counter III statistics per group Click Counter III can show you statistics per group     
or you can show several groups at once. Click Counter III statistics multiple groups
Click Counter III statistics per link And the same for the individual links: statistics per link...
or statistics for a selection of links, even from multiple groups. Click Counter III statistics multiple links
Click Counter III inline statistics And finally you can have inline statistics.

Revision History

Version Release Date Contents
v3.0 28 Aug 2020 Initial release

Sites Using This Add-on

Please add your site to the table if you use this modification.

URL User Note Mod-Version TNG-Version User-language
A Bisbee Family History Rick Bisbee A must-have for mod developers v3.0 12.3 English
Our Roy and Boucher Families Ken Roy Worked with Rick Bisbee to test this replacement of Bart's Click Counter II and Jeff Robison Click Counter II Email Notify v3.0 12.3 English, French
Family Histories Steven Davis v3.0 12.3 English