Click Tracking

Introduction

AutoGallery SQL 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, and is also nice to use with the permanent galleries so you know how many surfers are visiting them. This document will explain how to setup AutoGallery SQL to track the clicks sent to the galleries. Note that this feature can be used for permanent and submitted galleries, but not random galleries from text files.

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 = 'username';
$PASSWORD = 'password';
$DATABASE = 'database';
$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. 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. 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 AutoGallery SQL 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.

Permanent Galleries

To track the hits sent to permanent galleries, you need to pass the go.php script one more piece of information and make a small adjustment to the ID value that is passed to the script.
Note the addition of the &Perm=1 to the end of the query string and that the GALLERY_ID value has changed to PERMANENT_ID. Using this in a template directive would look like:
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.

Passing Arbitrary Values to Traffic Trading Scripts

If there is additional information that you want to pass on to your traffic trading script through the go.php script, you can configure custom template values in the $TEMPLATE setting to support them. For example, if you wanted to pass the gallery's category on to your traffic trading script, you could do this by adding the value to the go.php query string and then configuring the $TEMPLATE value to include that information in the traffic trading script URL.

Here is a brief example. Assume that your traffic trading script supports passing the gallery's category through it's c= option and the skim value through it's p= option, like so: To pass these values through the go.php script you would configure your TEMPLATE to look like this: Then you would need to configure the $TEMPLATE setting so the go.php script knows where to insert your arbitrary values. Each value that you pass through the go.php script will be converted into the standard template value format of ##VALUE##. So, for the category value of c=CATEGORY, this will become ##c## in the $TEMPLATE setting. Here is an example of how your $TEMPLATE setting would look: The go.php script will then replace the ##p## value with the p= value that was passed through it, and the ##c## value with the c= value that was passed through it. So, for example, if the p= value was 75 and the c= value was Hardcore, the converted URL would look like this: