[ic] How can I log search requests?

Mike Heins interchange-users@interchange.redhat.com
Sat Aug 11 13:43:01 2001


Quoting Mike Thompson (mthompso@nmsu.edu):
> I am interested in trying to capture and log search requests that are
> entered in by my customers from both the small and advanced search forms.
> 
> It is valuable to me to know what people are looking for when they come to
> my store.  Also even more valuable is to know what they are looking for but
> didn't find.
> 
> Has anyone already set up something similar?  Any ideas about how to go
> about this?  I didn't see anything in the archives.

I used to do this with a special feature, but as it turns out it
is much easier to do right on the results page. Use a hidden
parameter in any search forms called log_search_data:

<INPUT TYPE=hidden NAME=log_search_data VALUE=1>

Then, do in results:

    [no-match]
    [if cgi log_search_data]
	[tmp log_data]
	NOT FOUND: [value-extended name=mv_searchspec joiner=" AND "]
	from_page: @@MV_PREV_PAGE@@
	host: [data session host]
	username if logged in: [data session username]
	email: [value email]
	[/tmp]
	[calc]
		$Scratch->{log_data} =~ s/^\s+//mg;
		$Scratch->{log_data} =~ s/\s+$//mg;
		return;
	[/calc]
	[log file=logs/not_found interpolate=1][scratch log_data][/log]
    [/if]
    [/no-match]

You can get as fancy as you want with the data, even to the point of
doing a database import (not recommended, especially for DBM, mostly for
performance).

-- 
Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH  45013
phone +1.513.523.7621      <mheins@redhat.com>

When the only tool you have is a hammer, all your problems tend to look
like nails.  -- Abraham Maslow