Results 1 to 3 of 3

Thread: Get Google Query string..

  1. #1
    Join Date
    Apr 2008
    Location
    Little Office!
    Posts
    80
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default Get Google Query string..

    I have seen forums highlight what we searched on google to get to their site.

    is there a script that would allow me do the same???

    Thanks DD in advance... i know i will get it here but nowhere else.

  2. #2
    Join Date
    Apr 2008
    Location
    Little Office!
    Posts
    80
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    bump?

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I saw this thread earlier and wasn't sure how to do this. However, I have an idea. I don't know if this is a standard method, but one option would be the following:

    Check the HTTP Referrer, which is available as $_SERVER['HTTP_REFERER']. Although this information can be missing or incorrect, it is almost always correct. You can check if that URL is google, and if it is, then you can look at the search terms in the URL.

    A typical google URL will look something like this:
    https://www.google.com/search?q=test&.....

    What you need is the q=... part. That is the search term. So then all you need to do is use that information to see what they were searching for when they found your page.

    I'm not sure this would work, but it's an idea at least. And, generally, it should work for other search engines (yahoo, bing, whatever).


    The only problem with all of this is if google (or other search engines) use a redirection of some sort so that the query is no longer visible as the last page the browser accessed (instead some uninformative redirect URL).


    Of course if you want to keep this active throughout a visit to the site, you'd need to use cookies or sessions or something else after that first page loads since after that all links (and therefore all referrers) will be local URLs on your site.
    Last edited by djr33; 01-19-2012 at 10:22 AM.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •