Hello everyone!
I am trying to find the most effective way to parse my System.Web.HTTPRequest.UrlReferrer to find the search term that was used to drive the visitor to my site assuming they arrived at my site via a search engine results page.
I am thinking (hoping) I'd use the HttpUtility.ParseQueryString method, but my problem comes in trying to figure out what variable to parse for. I have the following list that I am required to check for. The list shows the search engine and the param that each uses.
daum:q,
eniro:search_word,
naver:query,
images.google:q,
google:q,
yahoo:p,
msn:q,
bing:q,
aol:query,
aol:encquery,
lycos:query,
ask:q,
altavista:q,
netscape:query,
cnn:query,
about:terms,
mamma:query,
alltheweb:q,
voila:rdata,
virgilio:qs,
live:q,
baidu:wd,
alice:qs,
yandex:text,
najdi:q,
aol:q,
mama:query,
seznam:q,
search:q,
wp:szukaj,
onet:qt,
szukacz:q,
yam:k,
pchome:q,
kvasir:q,
sesam:q,
ozu:q,
terra:query,
mynet:q,
ekolay:q,
rambler:words
So while I could go through each and say something like
NameValueCollection query = HttpUtility.ParseQueryString(UrlReferrer);
var referrer = Request.UrlReferrer.ToString();
if(referrer.Contains("google.com")
return (query["q"]);
else if(referrer.Contains("yahoo.com")
return (query["p"]);
I'm thinking there must be a better way since I have this nice name/value pair to work against,and the power of the ParseQueryString method, but I'm drawing a blank.