
Can I capture Google searches on my site?I see you've posted articles explaining how to put a Google Search Box and Search Results on a website. (see add Google search to your site). But is it possible to be able to store the search phrases typed into the Google search boxes? This way I can analyze the data to know what people are searching for, then create more content on that subject. Well, the answer is "yes and no". You can indeed capture the searches people do through a custom Google search box on your site, but it's a bit tricky and you need something that many people don't have, which is the ability to run custom CGI scripts on your Web server. The basic idea would be that instead of having the search form pointing directly to Google, it will point to a script on your site that captures their search term then hands the search itself along to Google, all in a fraction of a second. The script has the following line for the search box: <form method="get" action="http://www.google.com/search">
But if we change that to, say, action="http://www.myserver.com/savesearch.cgi", now we can write that script. Make it a rudimentary shell script and it would look like this: #!/bin/sh
log="/var/log/searchbox.log" echo $QUERY_STRING >> $log echo "Location: http://www.google.com/search&$QUERY_STRING" echo "" exit 0 Assuming you have everything set up properly, including the log file being writable by a script launched by the Web server, that's all you would need to be able to have a file called "searchbox.log" that stores all the search patterns people use. If you prefer Perl, C, or some other scripting language you can definitely accomplish the same with those languages, perhaps even more efficiently, but this gives you a sense of the basic methodology you'd want to use and how it could integrate into your site. Again, though, let me warn you that it's a lot more complicated than just adding a few lines to a Web page, and if you're not already comfortable monkeying with scripts on your Web server -- and have a Web server that will let you do that! -- then this might not be a good solution for you. Check with your Web hosting provider, they'll be able to let you know if this is something you can do or not!
Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Simpy.
Categorized:
CGI Scripts and Web Site Programming
(Article 7346)
Tagged: cgi, google search, scripting, tracking Previous: What is a book agent supposed to do for me as an author? Next: How do I set safe search (safesearch) preferences for Google? Subscribe!
Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.
Rather amazingly, there are no comments on this article yet.
I have a lot to say, but ...
I do have a comment, now that you mention it!
|
Search
Find just the answers you seek from among our 1700+ free tech support articles by using our Lijit search engine.
Help!
Subscribe to
Ask Dave Taylor!
Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.
Articles and Reviews
Auctions and Online Shopping Blogs and RSS Feeds Building Web site traffic Business and Management Cell Phones and Mobile Phones CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above HTML and CSS Mac OS X Help MySpace, Facebook, Twitter and Social Network Help Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Help Video Game Tips and Help Windows Help
Recent Entries
Join the List!
Book Links
|