Hi, I am trying to find a simple PHP script to do the following: 1. Searcher types "big blue widgets model 3344" into google.com 2. My URL comes up in the SERPS and the searcher clicks on it. 3. When my page loads I want the searcher to see his keywords as the title of the page. Any ideas? thanks, x
I don't know of any scripts to do this automatically, but it shouldn't be too hard. I'd simply look at the referer URL and pull it apart to grab the original search query.
There are lots of scripts doing this (or similar). Have done it myself in several sites. If you know regexp it should not be hard to solve taking point from $_SERVER['HTTP_REFERER'] as mentioned by TwistMyArm. Else; Read: http://alistapart.com/articles/searchhighlight/ http://suda.co.uk/projects/SEHL/ http://dev.wp-plugins.org/file/google-highlight/trunk/google-hilite.php?rev=204 Modify to your needs and you'r dig.
This should get you started: <?php $refurl = getenv("HTTP_REFERER"); $googleterm= explode("&q=", $refurl); $q= $googleterm['1']; if(trim($q) == "") { $googleterm= explode("&p=", $refurl); $q= $googleterm['1']; } $q= str_replace("+", " ", $q); print ' <html><head><title>'. $q. '</title> '; ?> Rest of page. Secondly, I am not sure how this is going to help you in anyway. Google won't index your site by searching it's own site first. If your site doesn't have a <title> at the time google indexed you, I am not very sure if they are going to rank you in SERPs. They use your title to be displayed in the link which searcher clicks. Bye
Interesting JEET, I'm just implement Google search results on-site instead of new window and this piece of code comes handy for the purpose. Thanks for posting
Yes I'm talking about that search box. I know I can't manipulate the results as per AdSense TOS but I will like to display the original query in a side column with other search tools so people who could not find it in Google take other options without lose track of the original query. Of course I will credit you, and in the meantime sending you some rep
Be careful with what you are planning to do... I read in terms that: You cannot populate the search box, You cannot use search box with competitor services. Don't risk anything you have... Thanks for the rep! Bye