Search code examples
search-engine

How does a website know the Google query I used to find it?


When I search for something such as "rearrange table columns in asp.net" on Google, and click the link to Wrox's forum site, the site greets me with a message such as "Your Google search for 'rearrange table columns in asp.net' brought you to Wrox Forum...".

How does a site know what query I typed into Google? And how could I add such an ablity to my site?


Solution

  • It is parsing your query from the query parameters in the HTTP_REFERER server variable, which contains the URL you're coming from and is provided in your HTTP request.