tags:

views:

462

answers:

1

In awstats I get a table with all the key words and phrases used to find my website. I would like to capture this myself however each search engine url is in a different format. When google is the referer I can use the variable q from the querystring as the search term (e.g. google.com?q=my+keywords) however another search engine may have the format searchengine.com?search=my+keywords

Is there a generic way of identifying search keywords? Or am I going to have to create a regex/filter for each search engine?

+3  A: 

One possibility is to just grab the referring URL ($_SERVER['HTTP_REFERER']) and parse out the keywords in it.

For example, check out this Google URL (searching for "stack overflow"):

http://www.google.com/search?hl=en&q=stack+overflow&aq=0&oq=stack+over&aqi=g10

The value of the q GET variable holds the keywords delimited by + signs.

Ryan Lewis
Microsoft's 'Bing' does the same thing, as does ask.com; Yahoo uses the 'p' GET variable. Whereas Wolfram Alpha "wasn't sure what to do with [my] input"...
David Thomas
@ricebowl: that's because wolfram alpha isn't a search engine, it is indeed a "computational knowledge engine".
Alix Axel
http://www.wolframalpha.com/input/?i=stackoverflow.com
Alix Axel
@eyze; that was quite interesting.
David Thomas