views:

145

answers:

6

Let's say I have google'd for digital photography school

http://www.google.com/search?q=digital+photography+school&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

I get few results.

And from the results if I click "Photography Tips & Tutorials" under subsection of first result "Digital Photography Tips: Digital Photography School"

On the digital photography school page I see something like this. -

Google Search Results

You arrived here after searching for the following phrases:

  • digital
  • photography
  • school

How does dps know that we came from google even with search terms?

+4  A: 

They can get the URL by reading the HTTP Referrer, and then they can parse the query string appropriately.

Brandon
If you use Firefox f.e., you can simply go to about:config and set network.http.sendRefererHeader to 0 instead of 2 and this won't happen because no Referrer will be sent anymore.
schnaader
Yes, it can be disabled, but that should be handled appropriately. Simply by not showing it at all, the code shouldn't be dependent on something that is not reliable.
Brandon
+1 to schnaader for extra tip.
Broken Link
A: 

The referring url is sent in the request headers. They parsed it to get your search terms.

David
A: 

I suppose they just parse Referer :) http://en.wikipedia.org/wiki/Referer

Rin
A: 

It will probaby look at the HTTP Referrer and then analyse the querystring.

Dan Diplo
A: 

They can simply check the referrer. Most web browsers have them enabled, only a few people disable them.

Kitsune
+1  A: 

Parse the referrer to get the query. Here's a PHP example:

<?php
    $referrer = parse_url($_SERVER['HTTP_REFERER']);
    if(strpos($referrer['host'], 'google') !== FALSE){
        parse_str($referrer['query'], $query);
        $words = explode('+', $query['q']);
    }
?>

The variable $words should now be an array containing all search terms. This could be improved upon to handle quotes and other special cases.

You