Blogger Hacks, Categories, Tips & Tricks

Thursday, April 26, 2007
BuzzFlux: Recent Search Queries
In my ceaseless quest for content to clutter up my blog's sidebar, I have found a rich new source: reader search queries, or "buzz". BuzzFlux allows you to retrieve and display these search queries in near-real-time, right in your sidebar, for the amazement of your readership. It also signals my return to blog-hacking after a six month hiatus.

Should I Do This?


First things first: is it a good idea to display your readers "live" search queries on your blog? On the plus side, it gives readers a good idea about what kinds of content your blog has (at least, as far as search engines and their users are concerned). In that sense, search queries may be considered as micro-content, a bit like tags. It may also help keep readers on your page, especially if coupled to your built-in blog search (see below).

On the downside, it may disturb some readers to see their recent queries displayed like this and some may be sensitive to the privacy side of things. Also, you have no control over what readers type into search engines, so you may be displaying potentially defamatory, profane or otherwise inappropriate content on your blog.

I'd be interested in Freshblog's readers' views on this one, so please chime in with your own thoughts on this question.

How Does BuzzFlux Work?


Most blogs worth their salt employ some sort of web stats service. Typically, you put a bit of code into your template that "phones home" to a central server every time a page is hit. Among other things collected is the referring URL, which contains the search query if the reader used a search engine to find your blog.

I think all stats services report on search queries. I use BlogFlux for some of my web reporting. They make some (though not all) of their stats available via RSS, which is handy for hacking. Unfortunately, the search queries page isn't one of them. To get the search page info in a useful form, I made a simple Dapp to retrieve the target page. (Here's the Dapp.) Once the contents are returned as a JSON object (an array of the top search queries), the BuzzFlux script just formats the results for display in the sidebar.

If there are more search queries than space permits, BuzzFlux "rotates" the queries every few seconds. (That is, it swaps in other queries at random).

As a nice add-on, readers can click on a search query of interest and my sidebar searching hack will scour your blog for that query, displaying the results in your sidebar too. By showing readers other people's queries and the results on the page, it's hoped that it will help readers find relevant content without leaving your site. (NB: This extension requires you to install the Recursive Backlinker hack.)

Check out the magic in action on The Speccy (scroll down to "Catch the Buzz" in the sidebar).

How Do I Install BuzzFlux?


First, go and register with BlogFlux and install their stats counter on your blog. (This hack doesn't have to rely on BlogFlux, but that's how it is at the moment.)

Next, put this in the header of your blog template:

<script type="text/javascript">
// BuzzFlux
Buzz = {"divid":"BuzzFlux", "limit":"15", "timer":"2000", "blogid":"1413", "period":"hour", "scan":"", "queries":[]};
</script>

<script type="text/javascript" src= "http://ghill.customer.netspace.net.au/buzzflux/buzzflux.js"></script>

The parameters are as follows:

divid = the ID of the div in your sidebar where all this content will be displayed.
limit = the number of queries to display at any given moment
timer = the delay (in milliseconds) between rotating queries
blogid = the BlogFlux ID number for your blog. Found in the URL of your results pages.
period = the period over which search queries are drawn. Allowable values are month, week and hour. Only use hour for high-traffic blogs since you want a reasonable number of queries to display (ie less than five search hits an hour and it will look a little sparse).
scan = the ID of your in-blog search field. Leave it as "" if you're not using the extension.

Now, edit your blog template to put this in your sidebar:

<div id="BuzzFlux" style="text-align: justify">   ... loading recent search queries ...</div>

Finally, you might consider throwing some CSS styling in. Either add these to your CSS file, or put them in the <style> part of your template header:

.BuzzList{ height: 9em; overflow: hidden; padding: 10px;}

a.BuzzItem{ text-decoration: none;}

a:hover.BuzzItem{ text-decoration: underline;}

Where To Next?


This opens up a range of possibilities. Not least is that FreshTags has for some time supported tag extraction from search queries, providing a means for some sort of query/tag cross-over. Another thought would be to use Yahoo's Pipes to merge, sort and process buzz from other (related? or rival?) blogs too.

As alluded to before, there are also pitfalls too. For example, who owns the copyright on a collection of search queries? Who's liable for publishing them? Of course, it's anonymous - to a degree. Without the aggregation effect of a Google Zeitgeist, it may be more like AOL's search debacle from last year.

Filed in: , , ,
Posted at 2:20 AM by Greg.
4 Comments:
<    >
Blogger Johan Sundström said...
Yay! Welcome back to hack land, Greg! :-)

<    >
Blogger Singpolyma said...
1) FreshTags detects referrer query
2) Query text and tags filtered from that text are logged
3) Tags are auto-expanded
4) Search results are auto-loaded/expanded
5) List of tags/queries from logs in sidebar

All optional and configurable, of course ;)

<    >
Blogger Greg said...
Thanks, Johan. I'll be sure to stamp my passport on the way out :)

Singpolyma, that all sounds good. At the moment, my blog does 1, 3, 4 and 5. (Google on drugs in AFL to see it pick up both the query and the embedded tag.)

Of course, we'd need to employ some stemming on the tags/queries to ensure we got enough hits.

Maybe we could mix it up with your tag synonym service too?

<    >
hi thanks, I will try to apply this hack to my blog. As I am a newbie, there will be some trials and errors on applying it, but that's okay. tanks!

Links to this post:

Create a Link


eXTReMe Tracker