Click Tracking

Introduction

TGP Rotator includes a PHP script that you can use to track how many clicks each of the galleries gets. This can be useful if you want to sort your galleries by their popularity. This document will explain how to setup TGP Rotator to track the clicks sent to the galleries.

The go.php Script

The first thing you need to do is edit the go.php script to setup it's variables. Open the go.php file in a text editor (we recommend EditPlus for Windows users) and locate the $USERNAME variable at the top of the file. You will see something similar to the following:

$USERNAME = 'devel';
$PASSWORD = 'devel';
$DATABASE = 'devel';
$HOSTNAME = 'localhost';

If you are not using a traffic trading script, you do not need to change the $TEMPLATE variable.
See the Traffic Trading Scripts section of this page if you want to use a traffic trading script and go.php at the same time.


Each of the variables has a comment following it that describes what it should be set to. Besides the MySQL options, there are a few other options that you can set which will determine how the script tracks each click and allows you to setup a template so you can use your traffic trading script. Once you have set the variables in the go.php script, you will need to upload it to a location on your server where it will run. On most servers you can have PHP scripts anywhere except inside the cgi-bin directory. We highly recommend that you place the go.php script in the same directory where your TGP pages are located. If you don't have it in the same directory, make sure to adjust your template so that your gallery links point to the correct loction of the go.php script on your server. Once you have the go.php script in a directory it can run from, you are ready to configure your TGP page templates.

Configuring Your Templates

The basic format that the go.php script expects to be called as is:
Where GALLERY_ID is the ID number assigned to the gallery by TGP Rotator and GALLERY_URL is the URL to the gallery. This is fairly simple to setup in your template using the HTML option of either the TEMPLATE, GALLERIES, or PERMANENT directives. A quick example should get you pointed in the right direction.
Note that the ##Encoded_URL## is a special template value for use with the go.php script. This template value will insert an encoded version of the gallery URL so that the go.php script can handle all possible URLs, including those with query strings and special characters.

Traffic Trading Scripts

If you are using a traffic trading script on your TGP and also want to count the number of clicks on each gallery, you will need to do some further editing to the go.php file. The $TEMPLATE variable is used to setup your traffic trading script URL. The default value for the $TEMPLATE setting is ##Gallery_URL## which will simply send the surfer directly to the gallery instead of through your traffic trading script. You will need to change the $TEMPLATE value so it points to your traffic trading script, and you will need to include the specific code that your traffic trading script needs to determine where it should send the surfer. For example, your traffic trading script may use a URL like this:
In this example, the p= value tells the traffic trading script what percent to skim and the url= tells the script what URL it should send the surfer to if it decides not to send the surfer to one of your trades. You will need to modify this URL to insert template values that the go.php script can understand. There are two template values you can use in the URL:
For the example traffic trading script URL above, your template would look like this:
The go.php script will take care of filling in those template values based on the information that you pass to it. For example, if you call the go.php script as the following:
The go.php script will call your traffic trading script like this:
The P= value that you pass to the go.php script is the value that will be used for the ##Skim## template value. Make sure when you setup your TEMPLATE directives that you pass a P= value to the go.php script if your traffic trading script supports skim values. Using the example above, your TEMPLATE would become this:
Note that you can use several different skim values by creating a separate TEMPLATE for each one. Then in your GALLERIES directives, use the appropriate template name for the skim value that you want to use for the galleries in that GALLERIES section. Example:
In the above example there are two templates, one that passes a skim value of 80 and one that passes a skim value of 70. There are also two GALLERIES section, one that uses the Text_80 template and one that uses the Text_70 template. The galleries that use the Text_80 template will send a skim value of 80 to your traffic trading script. Likewise, the galleries that use the Text_70 template will send a skim value of 70 to your traffic trading script.