Record MTSearch terms

If you use the amazing MTSearch add-on, then here is an awesome companion tool.

Graham has put together a way for you to make a text file (or web page) of the search terms visitors to your site use in the MTSearch tool.

Click here to read the hack.

I actually have had difficulty getting it to work, but several others have had great success. If you get it running, be sure and let me know in your comments. Don’t be suprised if I start asking you how to get it working for my site!

Enjoy!

UPDATE: Already posted? Dagnabbit! Well, my next post will be better!

9 Responses to “Record MTSearch terms”

  1. Jennifer Says:

    Promo (by the way, you need to update you “nickname” so you get credit for your posts…)

    you asked me if we posted a link to this, my bad - apparently we did (although, funny it didn’t come up when I did a search for “search” ???!!!)

  2. Keith Says:

    Just stopping by. Lovely site!

  3. robyn Says:

    I didn’t get it to work either — I wonder if it’s either a mySQL or Blogomania/HM thing?

  4. Christine Says:

    More than likely a MySQL/mt-search issue rather than a server issue. Has anyone contacted the original author to see if he has a fix for the MySQL version?

  5. robyn Says:

    I’m not so sure Christine — at Promo’s suggestion I just tried it on Todd’s blog which still uses the DB method, and unless I just did it horribly wrong, it still gave the same Internal Server Error it gave me using mySQL.

  6. kristine Says:

    I wanted to play with this, but decided to wait until sometime later this month because MT2.5 will have the MT search integrated into it. :)

  7. David Says:

    I took the liberty of extending the hack a little.

    I added display of the date, supression of logging blank searches, and an error exit if the log file can’t be written to.

    Here’s my version:

    # Log the search request

    # Ideally the two variables that follow would be in the mt-search.cfg file and read from there
    # But I don’t know how to do that
    # But the rest of the hack is written to allow for that future enhancement

    my $uselog = 1; # 1 = YES; 0 = NO
    my $logfile = “/full/path/to/log/file”;

    # Only write to log if configured to do so
    if ($uselog eq ‘1′) {
    # Only write to log is search string is not null
    if ($searchstr ne “”) {
    # Open the log file or display error and stop
    open (LOG, “&gt&gt$logfile”) or die “Can not open file $logfile: $!”;
    # Get the system date
    my $date = `date`;
    # Remove the carriage return from the date string
    chop($date);
    # Write the data to the file
    print LOG “$date”;
    print LOG ” - “;
    print LOG “$searchstr\n”;
    # Close the log file
    close (LOG);
    }
    }

    # End of logging hack

    I posted this on Graham’s site too, but thought I’d put it here, since this is what led me to the hack originally.

  8. Promo Says:

    Odd that it works for some folks and not for others. I wonder what the secret is?

  9. Anonymous Says:

    here