Plugging Away at Plugins
Interesting how things work sometimes depending on the test data. I use the WP-ShortStats plugin to keep track of the traffic statistics to my blog. And of course, one of the most interesting stats to watch is the search keywords because sometimes you get such weird stuff 🙂
I like the WP-ShortStat plugin because it is compact, unobtrusive and gives a lot of stats which warm the cockles of a geek’s heart 🙂 However, a couple of days ago, I noticed that the plugin was giving me only a couple of search keywords instead of the longer list I had been used to getting before that and none of the terms which had appeared for a couple of weeks before, were now appearing. I thought maybe there was some automatic purging code in place which removed older entries and thought no more about it. At least for the time being.
Today, I felt like doing a little bit of digging since the ShortStat display was getting cluttered by lots of spam referrers and so on. So I took a look at the plugin code. It turns out that the plugin simply pulls the last 100 records matching certain criteria to give a list of search terms. So I ran the query on my data to see what I got. I noticed that of the 100 records returned, very few actually were search queries 🙂
So I took a look at the SQL and the ShortStat plugin code to see if there was a way to improve upon the code. It turned out that I could add an extra condition to the SQL query to return results which were more likely to be search queries. I did that and I suddenly had a full list of search terms in my WP control panel again!
I’m sure that the WP-ShortStat developer did a lot of testing of the plugin before you released it. However, as I mentioned initially, sometimes it’s the data which determines what sort of output you get. And no, this is not really a bug in the plugin but it did explain some unexpected behaviour and in case somebody else is in the same position I was in, hopefully this clarifies what is going on 🙂