简体   繁体   English

您如何检测您的网站访问者是否来自谷歌搜索结果?

[英]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?当用户从谷歌搜索并从他/她在结果页面中显示的结果登陆我们的网站时,我的网站有没有办法检测到他来自谷歌?

Check the $_SERVER['HTTP_REFERER'] variable which should contain the referring URL.检查应该包含引用 URL 的$_SERVER['HTTP_REFERER']变量。 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.请注意,这不是防篡改或故障安全的,因为客户端可以轻松更改或修改Http-Referer header。

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:编辑:刚刚搜索了phpinfo (因为我得到了一个显示$_SERVER['HTTP_REFERER']变量的phpinfo()页面)来向您展示Http-Referer的样子:

$_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)...如您所见,您还可以提取谷歌查询中使用的搜索词(或检测搜索是否由谷歌浏览器地址栏发起)......

It looks like you can use the $_SERVER['HTTP_REFERER'] variable.看起来您可以使用 $_SERVER['HTTP_REFERER'] 变量。 But I think the value is controlled by the client and can't always be guaranteed to exist or accurate.但我认为该值是由客户控制的,不能总是保证存在或准确。

You would check the $_SERVER['HTTP_REFERER'] if you wanted to do it in PHP.如果您想在 PHP 中执行此操作,您将检查$_SERVER['HTTP_REFERER'] You can also use document.referrer in javascript.您也可以在 javascript 中使用document.referrer

Yes, use the HTTP_ REFERER var in the $_SERVER array:是的,使用 $_SERVER 数组中的 HTTP_REFERER 变量:

$_SERVER['HTTP_REFERER'];

This shoudl then include something like http://www.google.com/?q=etc这应该包括类似http://www.google.com/?q=etc

Note however that the REFERER is not always set because clients can disable their browser to send it in the request.但是请注意,REFERER 并不总是设置,因为客户端可以禁用他们的浏览器以在请求中发送它。

Check referrer of a request.检查请求的引用者。 It should contain www.google.com/...它应该包含 www.google.com/...

HTTP_REFERER: Returns a string containing the URL of the page that referred the request to the current page using an tag. HTTP_REFERER:返回一个字符串,其中包含使用标签将请求引用到当前页面的页面的 URL。 If the page is redirected, HTTP_REFERER is empty.如果页面被重定向,HTTP_REFERER 为空。

Using HTTP_REFERER used for ASP.使用用于 ASP 的 HTTP_REFERER。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM