Search Statistics PHP Script

Top  Previous  Next

If you have PHP support on your web server, you can use a provided script ("report.php") to provide online reporting for your search log. This allows you to provide live, up-to-date statistics on your website without needing to download the log file manually and generate/upload your report.

You can find this script in the "extras" folder. From the Zoom Indexer, click on the "Tools" menu and select "Open 'Extras' folder" to locate this file (also see "Where is the Program Data directory?").

screenshot_tools_extras

Installation

Copy or upload this script to the same folder as the log file on the server.

If your logfile does not have the default name of “searchwords.log” open the php script in a text editor and change this line:

$LOGFILENAME        = "searchwords.log";

To correspond to the filename of your log file.

Customization

PHP Variables

Inside the php script near the top of the file are customizable options. The php script can be edited with any basic text editor. To change an option you should edit the value to the right of the equals sign. If the value is encased in quotation marks they should be left in place. Also, the semi-colon at the end of each line must remain in place as well for the script to work.

$LOGFILENAME         = "searchwords.log";
The name of the log file that the statistics will be generated from.

$TEMPLOGNAME = "_tempsearchwords.log";
Name of temporary log file. This file will be created and written to during a trim operation. If the file already exists it will be overwritten.

$BAR_LENGTH = 300;
The length in pixels of the longest bar in each bar chart .

//$PASSWORD_REPORT = "password";
This is the password required to generate a report. Note that the line begins with //, this means that the line is commented and is not active. To enable password protection for generating a report remove the // from the beginning of the line and change “password” to whatever you would like the password to be.

//$PASSWORD_TRIM = "password";
This is the password required to trim a log file. Note that the line begins with //, this means that the line is commented and is not active. To enable password protection for trimming the log file remove the // from the beginning of the line and change “password” to whatever you would like the password to be.

$ENABLE_TRIM = 1;
This line enables or disables the ability of the script to trim a log file. By default this is set to 1 (on). If you would like to completely disable the trim functionality from the script please set this to 0.

$_DEBUG = 0;
Debug data on or off, you probably don't want to change this setting.

CSS Styles

Near the top of the PHP script are some CSS styles that can be used to change the look of the report. Feel free to edit these however you like.

Report Configuration

Start Date / Finish Date

The reports will be generated based on a date range specified in these fields. The date range is inclusive of the dates specified. The recommended format for entering dates is in the (year-month-day) format however the script is able to recognize many formats so you can try entering in the date however you like. The dates will be displayed in year-month-day format on the final report page so you will know if the script understood what you meant. Some example dates are:

•        “now” – Today’s date

•        “3rd March 2007”

•        “-1 Month” – Today’s date minus 1 month

Top 10 Search phrases

This provides a bar chart of the top 10 search phrases made on your website. This gives you a good indication of what people are looking for on your website.

Top 10 Search Phrases that returned no matches

This provides a bar chart of the top 10 search phrases on your website which found “no results”. This is useful for determining what your visitors are searching for on your website but not managing to find. You can use this information to provide content that better cater your website to your visitors (or determine what meta keywords to add to allow your users to find what they are looking for).

Searches per day

This provides a bar chart representing the number of searches that are made on your website per day.

Searches per week

This provides a bar chart representing the number of searches made on your website per week.

Searches per month

This provides a bar chart representing the number of searches made on your website per month.

List the top x searched words (sorted by popularity)

This option appends a HTML table of search words (sorted by popularity). You can specify the number of searched words you would like to list here.

Raw Data Output

A table containing the raw data from the log file for the date range specified. Because this data can be quite large a maximum of 5000 log entries will be displayed. If you need to see more consider opening the log file directly in a text editor.

Password

If you have enabled password protection for generating logs you will need to enter your password on the configuration page.

Trim Functionality

The trim section of the configuration page allows you to delete entries out of the log file, making it smaller and faster to generate reports from. Consider using this if report generation is taking too long or timing out. Please note however that this operation cannot be undone and any deletions are permanent.

Password

If you have enabled password protection for trimming the log file you will need to enter your password here.

Trim Log Entries Before

Any log entries before this date will be permanently deleted. Like the start/finish dates in the report configuration this field can take a number of formats, once you click the Trim Log button you will be taken to a confirmation page that will display the entered date in year-month-day format to confirm the script understood what you meant and to make sure you really want to delete the records.