How does the website know the Google query that I used to find it?
When I search for something like " rearrange table columns in asp.net
" on Google and click on the Wrox forum forum link , the site greets me with a message like "Your Google search for" reordering table columns in asp.net "brought you to the Wrox forum .. . ".
How does the site know which query I entered into Google? And how can I add such an absorption to my site?
+2
source to share
4 answers
It uses a header known as the "HTTP Referrer". See http://en.wikipedia.org/wiki/HTTP_referrer
To use it on your site, you will need dynamic page creation such as ASP / ASP.NET, PHP or Perl. For example, in Perl, you can do something like:
if ($ENV{HTTP_REFERER} =~ /google.com\?.+&q=(.+?)&/)
print "Your google search of $1 brought you to this site";
WARNING : the above code is just an example and may be wrong or safe!
+8
source to share