Site Search Analytics

Installation

 
Prelude.
Site Search Analytics works in conjunction with Google Custom Search, Google's free site search service.

The search results page must be a PHP web page. The search results page is where the Google Custom Search results are published after someone uses the site search box.

If you need to change the file name of the search results page, the action= URL of the site search box form must also be changed.

The action= URL can be changed right in the site search box form code. Or, if you prefer, you can log into the Google Custom Search control panel, use the "Code" menu link, specify the new URL, and then copy the new site search box code to replace your current one with.

If you do not yet have Google Custom Search installed on the domain where this Site Search Analytics software will be installed, then install the site search first. The online Adding Google's Site Search to Your Web Site article provides step-by-step instructions.

 
Step 1.
Two determinations need to be made:

  1. The subdirectory where the Site Search Analytics log file will be located. This is a subdirectory of your document root (or subdirectory of subdirectory).

    The document root is the directory where your domain's main/index web page file is located — the page that loads into your browser when you type your domain name into the address bar.

  2. The name of the site search log file itself.

For purposes of these instructions, we'll assume the following:

  1. Log file subdirectory — GoogleSearchLog
  2. Log file name — GoogleSearches.csv

Write those down. You'll need them in two of the following steps.

 
Step 2.
With your FTP program or server's file management interface, create the log file subdirectory.

Depending on how PHP is configured for your domain, the log file subdirectory may need 777 permissions. Most FTP programs and file management interfaces allow you to change file and directory permissions.

 
Step 3.
Paste this JavaScript into the source code of each web page that contains the Google Custom Search box form.

The above will set a temporary cookie to indicate which page was loaded into the browser. If the site search box is used, that cookie is consulted to determine which page it was used from.

 
Step 4.
Paste this PHP code into the source code of the search results web page.

Four values in the above code can be customized. You'll see them at lines 10 through 13. All values are optional.

  1. Email address —
    If you want an email sent to you every time someone uses the site search box, specify the address. Otherwise; leave it blank.

  2. Email subject —
    If an email is sent, what you specify here will be used as the subject line. If blank; a default subject line will be used.

  3. Log file directory —
    If you do not want a log file to be maintained, this can be left blank.

  4. Log file name —
    If you do not want a log file to be maintained, this can be left blank.

When the above PHP code is pasted into the search results page, logging can commence.

 
Step 5.
Open file SiteSearchAnalyticsControlPanel.php in a plain text processor, like NotePad or TextWrangler.

It is important that a plain text processor is used. Software able to format characters in ways other than plain text may insert incompatible characters, even if no such formatting is specified.

At lines 10 and 11 of the SiteSearchAnalyticsControlPanel.php file, you'll see places to specify the log file directory and the log file name. The name of the directory and the name of the file must be identical to what was specified in the PHP code in the previous step.

 
Step 6.
Upload file SiteSearchAnalyticsControlPanel.php to your server in a document directory. A document directory is a directory where web page file can be loaded into a browser.

Type the URL of SiteSearchAnalyticsControlPanel.php into your browser's address bar.

When a log file is available, the control panel will let you view the search terms and words in various ways. It will also allow you to download the raw CSV log file itself.

 
Thank you for using Site Search Analytics.

Will and Mari Bontrager
Willmaster.com