Monitoring Search Usage


Adding a customized search interface to your website can be a great boon to both you and your users. However, by simply providing the interface without monitoring, you are only receiving a portion of the available benefit. Keeping an eye on which words are searched for most often, and what links users select when performing those searches, can give you critical suggestions on which parts of your website are used most often or are hardest to find. Monitoring searches should be trivial, and you have a few options:

  1. Dump the cache database on a regular basis.

    Watch for reccurring searches over a period of time.

  2. Use your website stats to monitor searches.

    Because all search requests are performed with GET requests, they should prompt as unique URLs within your server logs.

  3. Modify the caching function to increment a separate database each time a query is run.

This will provide you with the most detailed set of results on which queries were performed most often. Rather than record simple totals, you may want to record the IP of the visitor with each query, and tabulate totals on a regular basis. This additional information will allow you to determine if users are performing multiple queries in search of a single piece of information.

Using the Search Data

An important item to note would be if a single search commonly had multiple pages of requested results. This shows not only that the item has proven difficult to locate on your site, but also that users are having a hard time selecting appropriate search terms to locate the result. You may want to reevaluate the position of that item within your site to make it more prominent, or use the fudging example shown later in the chapter to provide users with an easier method to access the desired information. Do not be alarmed when first presented with tabulated search information; research has shown that over half of Internet users are search-dominant. Search-dominant (see Designing Web Usability: The Practice of Simplicity, Jakob Nielsen, Publisher: New Riders; 1999) users are task oriented, and usually go straight for the search function on any site they visit (rather than attempting to use whatever navigational aids you have provided). So you will likely see a large number of searches for items that you had thought were easy to find. This is normal, and not generally cause for alarm.

Finding Which Search Results Are Useful

Knowing which searches are performed is useful, but only half the battle. Knowing which results users are selecting further enhances the picture of how the search function is being used. Tracking this usage has two key steps. First, rewriting the link provided in the search results, and second, creating an intermediate page for users to be sent to that redirects them to the appropriate search result.

Editing the link should be trivial:

 foreach($queryResults as $item) {   echo "<a href=\"http://example.org/jump.php?     q={$searchQuery}&t={$item['URL']}\">{$item['title']}</a><br>";   echo $item['snippet'] . "<br><br>"; } 

The target URL for the link is simply rewritten to point to the intermediate page. t & q are selected for the GET variable names rather than something more understandable (such as target and query, respectively) in an effort to keep the URL as short as possible. To shorten the URL further, name your script with a single character name ("j" for example, no extension), and instruct your web server to interpret that page as a PHP script.

Creating the intermediate page isn't much more difficult:

 <?php require("../common_db.php"); $linkID = db_connect(); $DIRTYtarget = $_GET['t']; $query = mysql_real_escape_string($_GET['q'], $linkID); $target = mysql_real_escape_string($DIRTYtarget, $linkID); $ip = $_SERVER['REMOTE_ADDR']; $query = "INSERT INTO 06_google_cache_clicked (time, query, url, ip)   VALUES(null, '$query', '$target', '$ip')"; insertQuery($query); header("Location: $DIRTYtarget"); ?> 

The code is pretty unremarkable; I choose to save the IP of the user in an attempt to get some handle on when users need to click on multiple links to find the data they are looking for. If your site requires a login, and as such additional data is available (generally either from a cookie or session data), you may want to store that instead. Conversely, you may want to store the MD5 of the user's IP in an effort to protect their privacy (this shouldn't be considered secure, however, because a brute force attack to determine which IP corresponds with a given hash is possible).




Professional Web APIs with PHP. eBay, Google, PayPal, Amazon, FedEx, Plus Web Feeds
Professional Web APIs with PHP. eBay, Google, PayPal, Amazon, FedEx, Plus Web Feeds
ISBN: 764589547
EAN: N/A
Year: 2006
Pages: 130

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net