How to capture keywords?

Discussion in 'Programming' started by dry_aquaman, Jul 9, 2006.

  1. #1
    I use a formMail form to collect on my site details that a user enters.
    All the traffic comes directly from the 3 big search engines.

    Does anyone have a clue as to if it is possible to collect the keyword or keyphrase that the user entered in Google?

    My guess would be that there is some variable being passed by the search engines but I've no idea how to collect it an pass it back in the form.

    Dry Aquaman
     
    dry_aquaman, Jul 9, 2006 IP
  2. Darrin

    Darrin Peon

    Messages:
    123
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Depending on what server side coding you are doing (PHP, ASP, etc), you want to find the referrer variable that is passed in the request. This will give you the URL that the request came from to go to your site. If you notice when you search on Google, MSN, Yahoo, etc., after you submit your search, it shows up in the URL. When you click on a link in the search results, that exact URL is passed to the site as a referrer parameter.

    You can then split that parameter out to get the individual key words from the query string paramters.

    For example: Here is my search for "Home Loan":
    http://www.google.com/search?hl=en&lr=&q=Home+Loan&btnG=Search

    "http_referrer" is a common server variable name for this (off the top of my head). I'm sure this is the one for asp, not sure for PHP. When you get the referrer string, it will be the entire URL. You will have to parse it out from there to get the key words. Maybe do a split function if you have it, split by '&''s and then by plus's?

    Hope that helps.
     
    Darrin, Jul 9, 2006 IP
  3. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #3
    just off the top of my head:
    asp: Replace(Request.Querystring("q"),"+"," ")
    php: str_replace("+"," ",$_GET['q']);
    coldfusion: Replace(Url. Something? hehe
     
    ccoonen, Jul 11, 2006 IP
  4. uniqueasitis

    uniqueasitis Peon

    Messages:
    661
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #4
    just remember that http_referer although the only option is not reliable. The browser may not send the variable due to security reasons. Hence, check for errors when using it.
     
    uniqueasitis, Jun 20, 2007 IP