Gossamer Forum
Home : Products : DBMan : Discussions :

Search tracking

Quote Reply
Search tracking
I see this subject was touched on a couple of years ago and I was wondering if anyone has found a way to do the following:

a user goes to the search form, enters information to search on (zip code or state) - what we would like to do is capture what they are searching on so we can generate statistics on those searches

can it be done????

TIA Unsure
Quote Reply
Re: [lookerjdc] Search tracking In reply to
Yes, this has been done. Search for this thread:

Topic: This mod logs your keyword searches
Cacan - July 22, 1999

Which is listed in the FAQ under "Searching" as:

Search Word Log
Search Log Table-izer by Crow

there also may be some other options listed in the FAQ.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Search tracking In reply to
http://www.monster-submit.com/mods01.html doesnt exist anymore - do you know where I can get a copy???
Quote Reply
Re: [lookerjdc] Search tracking In reply to
There is a copy posted within the FAQ noted below. It has the external link and a copy of the mod within the thread I noted above.

Another thread to check is "Log Search Results" which is another version.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Search tracking In reply to
I see now where the results are being written to the log file, but there is no keyword file being created, and i cannot execute keyword.cgi (and I have changed persmissions on the file)....

what (besides everything) am I doing wrong Blush
Quote Reply
Re: [lookerjdc] Search tracking In reply to
Which version are you using? One makes the entries in the log file and the other creates a text file defined in your .cfg file:

in your default.cfg add this line:

$kword_file = $db_script_path . "/keywords.txt";

If you are using the second version are you putting both the .cgi and .txt file in the same directory as your dbman files?

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Search tracking In reply to
we have tried both versions

the one that places the info into the log file seems to be working fine, but it also seems to be an 'ugly' solution in terms of being able to filter out only that data from the log file.

we did include that line in default.cfg (as noted below)

);

# Default maximum number of hits returned in a search.
$db_max_hits = 30;
# Bold search results (1 = Yes, 0 = No).
$db_bold = 1;
# Regular and title fonts used in auto_generation and html.pl.
$font = 'font face="Tahoma,arial,helvetica" size="2"';
$font_title = 'font face="Tahoma,arial,helvetica" size="4"';

$kword_file = $db_script_path . "/keywords.txt";

# Authorization Options


but do not know see any keywords.txt file being created and (here is the stupid question), how do we call keyword.cgi??
Quote Reply
Re: [lookerjdc] Search tracking In reply to
The script is setup to write to and read the keywords.txt file. You must create this blank file and put it into the same directory as your dbman files. You might also want to chmod this to 666.

You should be able to call the keywords.cgi script in your browser by typing the full url to the file.

For instance: http://yourserver.com/path to dbman files/keyword.cgi

First you will want to do a few keywords searches so that your keywords.txt file will contain some entries.

You could even provide a link in you footer to display the keyword.cgi such as:

print qq!| <A HREF="keyword.cgi">View Keyword Search results</A> ! if ($per_admin);

Hope this helps

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Search tracking In reply to
I really appreciate all the time and effort you are spending with me trying to get this working, but I must be missing something (besides my brain...)

here is the keyword.cgi code:



#!/usr/local/bin/perl5
#
# Sort Routine was written by Alex Krohn ( thanx a million )
# This script is little more than the sort routine. It
# Just takes the Keyword Mod and makes a nice pretty table out of it.
# Thought this would be useful if you wanted to show it to your users, or just make it easier to read.
#
# This script uses The Search Log mod found at
# http://www.monster-submit.com/mods01.html Its easy to install and counts each search.
#
# Send Feedback to crowe@darkspiral.com
#
############################################################

print "Content-Type: text/html\n\n";
# If greater than this number the script will highlight those entries.
$targetnumba = 5 ;

# Print out the HTML that Appears BEFORE the sorting.

print "<HTML><HEAD><TITLE>Keyword List Html Build</TITLE></HEAD>\n";
print "<insert body tag here><center>\n";

print "<br><br><a href=keyword.cgi>Build Keywords</a><br><br>\n";
print "<font size=1>Currently Highlighting words greater than</font> <font color=RED>$targetnumba</font> <font size=1>searches.</font> <br><br>\n";
print "<table width=600 border=1 cellpadding=0 cellspacing=0><tr><td>Keyword</td><td>Number of Searches</td></tr>\n";

# Open The DB, Sorts and Print out the Results.
# I run mine from the same dir as my Keywords.txt file, change it to your full path if you want people to have access to it.

open (DB, "keywords.txt") or die $!;
while (<DB> ) {
chomp;
($name, $score) = split /:/;
$scores{$name} = $score;
}
close DB;
foreach $word (sort { $scores{$b} <=> $scores{$a} } keys %scores) {
if ($scores{$word} > $targetnumba)
{
print "<TR align=left><TH><$font><em>$word</font></em></TH><TH><$font><em>$scores{$word}</em></font></TH></TR>\n";
}
else {
print "<tr><td><$font>$word</font></td><td><$font>$scores{$word}</font></td></tr>\n";
}
}
# Prints the End of the HTML
print "</table><br><br><font size="1">Search Log Table-izer by Crowe\@darkspiral.com</font></center></BODY></HTML>\n";

---
and here is the line of code in default.cfg:

$kword_file = $db_script_path . "/keywords.txt";


I created a file called keywords.txt and placed a copy in the same dir as dbman, and also to be safe I placed a copy one level up from the dbman folder - i have run a few searches and it does not appear anything is getting written to the file
Quote Reply
Re: [lookerjdc] Search tracking In reply to
I do have this working for the DBMan FAQ so I'm not sure anything is wrong with the coding.

Do you set to the correct path to perl for your server:

#!/usr/local/bin/perl5

You also need to insert your body tags in the code such as:

print "<insert body tag here><center>\n";

should look something like this:

print "<BODY BGCOLOR="#FFFFFF" TEXT="#110000" LINK="#3333FF" VLINK="#23238E" ALINK="#000000">\n";

If you add the keywords.txt file in a file one directory up from your dbman files then in the following line use the full PATH (not url) to the .txt file:

open (DB, "keywords.txt") or die $!;

Perhaps for some reason it's not able to write to the file, if for instance you have this within your cgi-bin directory.

Did you try setting the keywords.txt file to 666?

If you view the file using FTP is it remaining empty?

I'm really not sure it's not working for you. There is nothing wrong with the coding.

In your db.cgi file did you make the change in sub query? It would look like this:

# First thing we do is find out what we are searching for. We build a list of fields we want to search on in @search_fields.
if ($in{'keyword'}) { # If this is a keyword search, we are searching the same
&track_kwords; ## Log Table-izer
$i = 0; # thing in all fields.

There are built-in errors messages, are you getting any error messages when you perform searches? It would warn it that it can't write to the file.

Just for the heck of it in your .cfg file move the line:

$db_debug = 0;

to above the section: # File and URL's

and turn on debugging to see if you get any error messages.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/

Last edited by:

LoisC: Oct 19, 2002, 8:44 AM
Quote Reply
Re: [LoisC] Search tracking In reply to
yes, the path is set:

#!/usr/local/bin/perl5

i added a copy of the blank keywords.txt file in both directories just to see if possibly it was looking to write outside the current directory - both files remain blank, and i have done numerous searches to test it

I have the file actually set to 777 just to make certain there is no problem there - once i can figure out what is going on I will crank the persmissions down

yes, the file is empty in ftp

its a mystery to me too.....


here is the code snippet from db.cgi:

# First thing we do is find out what we are searching for. We build a list of fields
# we want to search on in @search_fields.
if ($in{'keyword'}) { # If this is a keyword search, we are searching the same
&track_kwords;
$i = 0; # thing in all fields. Make sure "match any" option is
$in{'ma'} = "on"; # on, otherwise this will almost always fail.
foreach $column (@db_cols) {
if (($db_sort{$column} eq 'date') or &date_to_unix($in{'keyword'})) { $i++; next; }
if ($i == $auth_user_field) { $i++; next; }
push (@search_fields, $i); # Search every column
$in{$column} = $in{'keyword'}; # Fill %in with keyword we are looking for.
$i++;
}
}


there are no error messages being generated

welcome to the twilight zone......
Quote Reply
Re: [lookerjdc] Search tracking In reply to
It is a mystery indeed. Everything else is working in your database?

You might try deleting the files on your server before uploading the files again with the changes. If that still doesn't work make a .txt copy of your .cfg and db.cgi files and provide the urls to where they can be viewed. Perhaps something else may be causing the problem.

Can you provide the url to your database.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Search tracking In reply to
Here is a copy of the keyword.cgi file I am using:

print "Content-Type: text/html\n\n";
# If greater than this number the script will highlight those entries.
$targetnumba = 5 ;
$font = 'font size=2';

# Print out the HTML that Appears BEFORE the sorting.

print "<HTML><HEAD><TITLE>Keyword List Html Build</TITLE></HEAD>\n";
print "<BODY background=\"../../images/bkgrnd1.gif\" BGCOLOR=\"#FFFFFF\" TEXT=\"#110000\" LINK=\"#3333FF\" VLINK=\"#23238E\" ALINK=\"#000000\">\n";
print "<P><center><a href=\"keyword.cgi\">Build Keywords</a><br><br>\n";
print "<font size=1>Currently Highlighting words greater than</font> <font color=RED>$targetnumba</font> <font size=1>searches.</font><P>\n";
print "<table width=600 border=1 cellpadding=0 cellspacing=0><tr><td>Keyword</td><td>Number of Searches</td></tr>\n";

# Open The DB, Sorts and Print out the Results.
# I run mine from the same dir as my Keywords.txt file, change it to your full path if you want people to have access to it.

open (DB, "keywords.txt") or die $!;
while (<DB> ) {
chomp;
($name, $score) = split /:/;
$scores{$name} = $score;
}
close DB;
foreach $word (sort { $scores{$b} <=> $scores{$a} } keys %scores) {
if ($scores{$word} > $targetnumba)
{
print "<TR align=left><TH><$font><em>$word</font></em></TH><TH><$font><em>$scores{$word}</em></font></TH></TR>\n";
}
else {
print "<tr><td><$font>$word</font></td><td><$font>$scores{$word}</font></td></tr>\n";
}
}
# Prints the End of the HTML
print "</table><P><font size=\"-1\">Search Log Table-izer by Crowe\@darkspiral.com</font></center></BODY></HTML>\n";

Please not I defined the font tag variable within the script. One other thing you might not realize is that the line:

$targetnumba = 5; # Highlights words greater than 5 searches.

Will only display the list of words that have been searched for more than 5 times. For testing purposes you might want to change this to a lower number such as:

$targetnumba = 2;

and then be sure to search for each word at least 2 or more times.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/