|
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!
Categorized:
CGI Scripts and Web Site Programming
(Article 7346,
Written by Dave Taylor)
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!
Rather amazingly, there are no comments on this article yet.
I have something to say, now that you mention it, but ...
I do have a comment, now that you mention it!
|
Recommended
Recent Entries
Search
I Need Help!
Apple iPad Help
Articles and Reviews Auctions and Online Shopping Blogs and RSS Feeds Building Web Site Traffic Business and Management CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above Facebook Help Google Plus Help HTML and CSS Industry News and Trade Shows iPhone and Cell Phone Help iPod, Sony PSP and MP3 Player Help Mac OS X Help Pay Per Click (PPC) Advertising Search Engine Optimization (SEO) Shell Script Programming Tech Support Video Help The Writing Business Twitter, LinkedIn and Social Network Help Unix and Linux Help Video Game Tips and Help Windows PC Help WordPress Help |