I think that Google’s “I’m Feeling Lucky” button is great fun and want to have that feature on my site, but before I start digging into any sort of coding, can you tell me, how does it work?
Before you tire out your brain too much, I should tell you that the “I’m Feeling Lucky” button is ridiculously simple: it takes you to the #1 match for the given search term or keyword. That’s all. No randomization, no selection of one of the first ten, just the #1 match.
For example, let’s say I searched on “diamond watch, mens” on Google (you can too: search). The results clearly show that the top match is the shopping comparison site TraxNYC.com:
Now, go to the Google home page and again type in “diamond watch, mens”, but this time, instead of clicking on “Search”, click on “I’m Feeling Lucky”.
Ahhhhh… now you know the secret!
To add an “I’m Feeling Lucky” feature to your own site is straightforward, albeit a bit tricky since Google makes it hard to read their Web pages because there’s so much going on behind the scenes. In a nutshell, though, here’s their home page search box:
<input name=hl type=hidden value=en>
<input maxlength=2048 name=q size=55 title=”Google Search” value=””>
<input name=btnG type=submit value=”Google Search”>
<input name=btnI type=submit value=”I’m Feeling Lucky”>
</form>
We can simplify it a bit, but it turns out that if you just remove the “Google Search” button and only have “I’m Feeling Lucky”, you get exactly the functionality you seek:
<input name=q size=30 value=”” />
<input name=btnI type=submit value=”I’m Feeling Lucky” />
</form>
Here’s how it looks in action:
It’s not too complicated, really. You can change the label on the button by changing what’s specified in the value= field, as you desire, and if you’d like to have the result show up on a new page, rather than replacing the current page, add target=”_blank to the form tag as an attribute.
Hi Dave. tnx for the help, but do you know how I can implement this “I’m Feeling Lucky” in sharepoint 2010 enterprise search?
Well I noted it works if it is a definate keyword… try it with more unlnown words and then with more known words… it is more likely to work with known words…
I am goin to check if it is working with google coop
,aybe it has the script built in to select the next best option.
I’m noting too that the “feeling lucky” code here only sometimes works, but the same search done directly on the Google page always works.
Interestingly while “banana” will take you strait to the Wiki page, if you do a site search within Wikipedia “site:en.wikipedia.com banana” the lucky button fails.
Banana does work Dave, takes you to banana in wikipedia.
But … here’s one for you …
type: moviemeter birth
What do you see when you perform the search from your site and what do you see when you perform the search from the google site?
I have to say I have no idea what you’re talking about, gang. I just typed in “banana” on the search box above, clicked on “I feel lucky” and was quickly taken to the #1 Google match — Wikipedia. What do you see when you try this same search, and what browser are you using?
when I have searched for “banana” it took me to below link:
https://www.google.com/url?q=https://www.livescience.com/45005-banana-nutrition-facts.html
Tha’s not good.
Why do you think that’s not good? Where would you have expected Google would take you on a “feeling lucky” link for “banana”, Kaushik?
This isn’t very helpful Dave.
Why didn’t you test it yourself before posting?
It only works on google pages.
Maybe you can tell us why?
Actually, Google’s own example doesn’t either…
http://www.google.com/help/features.html#lucky
2 x :o(
Doesn’t work if you enter a search term and press the Enter key, you get normal search results page instead. :o(