有没有一种可靠的方式来获取引用网址而不依赖于$ _SERVER? [英] Is there a reliable way to get the referring url without relying on $_SERVER?

查看:127
本文介绍了有没有一种可靠的方式来获取引用网址而不依赖于$ _SERVER?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在根据Google和Bing PPC广告系列定制我的网站的内容。如果用户点击PPC广告,他们会看到特定的内容。如果他们通过有机搜索来到网站,他们会看到不同的内容。如果他们直接来到,他们会看到第三个内容。
它正在工作,但并不一致;结果不像预期的那样行事,并且PPC广告通常会显示有机内容。
我知道HTTP_REFERER不能被信任,所以也许这是导致问题的原因。
无论如何,有没有更好的方法来做到这一点?我可以使用Google Analytics和/或 https://代码中的内容。 google.com/p/gapi-google-analytics-php-interface/ 可靠地获取引荐网址?
感谢您的任何建议。

I'm customizing the content of my site based on Google and Bing PPC campaigns. If a user clicks a PPC ad, they see certain content. If they come to the site via organic seach, they see different content. If they come direct, they see a third content. It's working but not consistently; results are not behaving as expected, and often PPC ads will show the organic content. I know HTTP_REFERER can't be trusted, so maybe this is causing the problem. In any case, is there a better way to do this? Can I use Google Analytics and/or something in https://code.google.com/p/gapi-google-analytics-php-interface/ to reliably get the referring URL? Thanks for any advice.

推荐答案

根据用户是否从搜索引擎点击您的网站来显示不同的内容或直接键入URL是不可能的,即使使用 $ _ SERVER ,甚至使用 $ _ SERVER 是不可靠的,因为它可以很容易被伪造。然而据我所知,向搜索引擎提供不同的内容(也称为隐形)是一种快速的方式来让你的网站被禁止和/或处罚。所以我会不惜一切代价避免这种情况。

Showing different content based on whether the user clicked to your site from a search engine or typed the URL in directly is not possible without using $_SERVER, and even using $_SERVER is unreliable since it can easily be forged. However as far as I know, providing different content to search engines (also known as cloaking) is a quick way to get your site banned and/or penalized anyway. So I would avoid this at all costs.

对于CPC广告系列,这很容易。只需设置不同的网址,例如 http://www.yoursite.com/?cpc=adwords,那么如果设置了 $ _ GET ['cpc'] ,设置一个会话变量并将它们重定向到同一页面,但没有 $ _ GET 参数。当然,会话cookie也可以被删除/禁用,所以即使这不是100%可靠。

For the CPC ad campaign, this is easy. Just set a different URL, eg http://www.yoursite.com/?cpc=adwords, then if $_GET['cpc'] is set, set a session variable and redirect them to the same page but without the $_GET parameter. Of course, session cookies could also be deleted/disabled, so even this is not 100% reliable.

这篇关于有没有一种可靠的方式来获取引用网址而不依赖于$ _SERVER?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆