1

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.

Ben Dunkle
  • 191
  • 1
  • 7
  • 1
    No. http://stackoverflow.com/questions/165975/determining-referer-in-php – Matt Nov 03 '14 at 19:32
  • @mkaatman you've summed it up quite nicely in just 3 characters =) – MonkeyZeus Nov 03 '14 at 19:40
  • My question isn't whether I can use HTTP_REFERER, it's whether I can use Google analytics or something else. I get it if the answer's no, but that link only tells me what I already know. – Ben Dunkle Nov 03 '14 at 19:45

1 Answers1

0

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.

Mike
  • 23,542
  • 14
  • 76
  • 87