00414: Option for logging search strings
Description: I was looking for a way to log the SearchWiki search strings in order to find out what people are looking for so that I could make it easier accessible and fix my navigation structure where necessary.
I came up with the following crude solution for 1.0.14:
I added the following lines to the function SearchResults in search.php:
$storefile = "/path/to/my/logfile/searchlog.txt"; $file = fopen($storefile, "a"); fputs($file, $Search['text']."\r\n"); fclose($file);
This writes all searchstrings into the logfile as a single line separated by CRLF so that I can simply view the file by clicking a link on my admin wiki page. (I selected a path in the upload tree to make this possible.)
I'm aware this is not the way it should be done since everything is non-optional, non-configurable and hardcoded into a PmWiki distribution file, but being PHP-illiterate, that's the best I could do :-)
Since this feature (in a fully developed version) might be interesting for others, too, and I don't think my solution is good enough for the cookbook, please consider this a feature request.
--Henning April 01, 2005, at 08:50 AM
My typical suggestion for this has been to use the webserver's access logs to find search strings and discover navigation issues, rather than reinvent the wheel and add yet another log to the system. In fact, many log analysis tools will already strip out the search terms and present a report of "most popular search terms".
OTOH, I do recognize that it's very difficult to find good access log analysis tools. If I weren't writing PmWiki I'd probably be writing a decent open-source log analyzer. :-)
--Pm
My log analyzer, analog, doesn't seem to recognize a PmWiki search as a candidate for a "most popular search term". The only things that appear there are Google searches and the like. In the Request Report that analog produces, it lists "/Main/Search/", but no hint of what people searched for. I like Henning's scheme -- why not just have a page called Main.SearchRequests that logs the searches? --GrahamL
OK, I admit this feature could be seen to contradict the PmWiki Philosophy:
3. Avoid gratuitous features
On the other hand, setting up a log analyzer seems rather difficult to me (I had a look at it and then decided I would get quicker result from the above solution), so the way I see it, my suggestion complies with another philosophy statement instead:
5. Be easy to install, configure, and maintain
--Henning April 04, 2005, at 10:16 AM
I just noticed that due to the sequential logging of the search strings, browsing the list of search results with the back button results in multiple identical log entries. I have decided to consider this a feature since it gives a rough idea of how many pages of the search results were viewed :-)
--Henning April 07, 2005, at 03:03 AM