Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
409 views
in Technique[技术] by (71.8m points)

php - how do you detect if your website visitor came from a google search result?

when a user searches from google and lands on our site from the results he/she was shown in the results page, is there a way for my site to detect that he came from google?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Check the $_SERVER['HTTP_REFERER'] variable which should contain the referring URL. Please note that this is not tamper-proof or fail-safe as the Http-Referer header can easily been changed or modified by a client.

EDIT: Just googled for phpinfo (because chanes were high that I get a phpinfo() page that shows the $_SERVER['HTTP_REFERER'] variable) to show you how the Http-Referer will look like:

$_SERVER['HTTP_REFERER'] = "http://www.google.de/search?hl=de&q=phpinfo&btnG=Google-Suche&meta="

As you see, you can also extract the search term used in the google query (or detect if the search was initiated by the Google Chrome address bar)...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...