问题
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.
回答1:
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.
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.
来源:https://stackoverflow.com/questions/26721402/is-there-a-reliable-way-to-get-the-referring-url-without-relying-on-server