Smells like a Google Search: Easily grab inbound search terms in Rails using search_sniffer
by Wynn Netherland
Thu, 17 Jul 2008 02:27:00 GMT was interesting enough to generate 5 comments so far
Sure you can mine your referrers in Google Analytics, but why not tailor your site to your users by peeking at what they were looking for when they found your site? The search_sniffer plugin makes it too easy to do just that.
Make your site sticky, give ‘em more of what they want
Once you get folks to your site, the goal is to keep them there. On MindBites, we wanted to provide additional suggested content based on any search terms that led them to the site. The good news is that getting these terms is as easy as parsing the HTTP_REFERER from the HTTP request. Unfortunately, the format of this url differs between search engines.
With nearly 70 percent market share let’s take look at a Google example. A search for “Ruby on Rails Houston” from the Firefox search box results in the following URL:
We only care about the q parameter, “ruby on rails houston.” Since “on” is such a common word, we really only care about “ruby rails houston.” The SearchSniffer plugin includes a list of common English words that are removed from the search terms by default.
How do I get it?
Installation is easy from Github
script/plugin install git://github.com/squeejee/search_sniffer.git
How do I use it?
class ApplicationController < ActionController::Base
before_filter :sniff_referring_search
...
end"
The plugin populates the @referring_search object containing info that can be passed to a keyword highlighter or internal site search engine to pull related content.
@referring_search.search_terms
=> "ruby rails houston"
@referring_search.raw
=> "ruby on rails houston
@referring_search.engine
=> "google"
The plugin supports all the major search engines including Google, Yahoo!, MSN, and more.
Let us hear from you!
If you find it useful, or have ideas for improvement, let us know!
Trackbacks
Use the following link to trackback from your own site:
http://locomotivation.com/trackbacks?article_id=smells-like-a-google-search-easily-grab-inbound-search-terms-in-rails-using-search_sniffer&day=17&month=07&year=2008
Comments
1 day later:
What a neat, effective way to improve the user experience for your users. I love it.
3 days later:
I hope you didn’t look at the similar Wordpress-Plugin cuz that’s reacting on referers from Google Reader too which always looks funny stupid.
7 days later:
hi,
Great plugin. Newbie question how can i use it to server content based on the search term?
Some examples would be nice!!
Thanks..remco
7 days later:
Love it! We use The Mole to track user paths through our application(MyTripScrapbook.com). With your search_sniffer we now display the search terms at the beginning of the user path as well. Very nice – thanks for the effort and making it available.
7 days later:
@remco
The idea is you would take the search terms and pass it to a search engine or an ActiveRecord find and use that to shape the content for your users. Jim has a great write up on using Xapian to do that.
@Jim
Thanks for the Mole tip. Glad to see new ways to use it!
Have a take?