Capturing search keywords in php
In awstats, I get a table with all the keywords and phrases used to find my site. I would like to capture this myself, however each search engine url is in a different format. When google is a referent, I can use the q variable from the querystring as the search term (for example google.com?q=my+keywords), however another search engine can have the format searchengine.com?search=my+keywords
Is there a general way to define keywords? Or do I need to create a regex / filter for each search engine?
source to share
One possibility is to simply grab the referenced URL ( $_SERVER['HTTP_REFERER']
) and parse the keywords in it.
For example check this google url (search 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 contains keywords separated by + characters.
source to share