Note that there are some explanatory texts on larger screens.

plurals
  1. POHTTP_REFERER and https
    text
    copied!<p>I'm trying to work out how to establish whether or not a visitor to a site I built has come from Google or not. The client is running an Adwords campaign and Google has objected to the fact that the user is redirected when they arrive at the site, so I need to add an exception for this.</p> <p>It has to be handled by PHP rather than the Analytics JS because the module which handles the redirects executes before any output is even sent to the browser, and it is easy to add in an exception as there are already exceptions for API calls. In the past I'd have just used <code>HTTP_REFERER</code> for this but my understanding is that since Google has started using <code>https</code> for logged in users and plain old <code>http</code> for non-logged in ones, the headers and <code>HTTP_REFERER</code> are not available for a chunk of the inbound traffic from Google.</p> <p>This Q&amp;A -> <a href="https://stackoverflow.com/questions/15781034/i-want-to-get-original-referer-url-from-google-search-with-php">Get Original Referrer URL from Google Search with PHP?</a> suggests that only the query becomes unavailable. But this one -> <a href="https://stackoverflow.com/questions/6880659/in-what-cases-will-http-referer-be-empty">In what cases will HTTP_REFERER be empty</a> , with a lot more upvotes, suggests that <code>HTTP_REFERER</code> will be empty.</p> <p>However my own tests on my own site when logged in to Google and when Googling incognito suggest that <code>HTTP_REFERER</code> <strong>and</strong> the querystring are available regardless of the protocol Google is using. So I can Google '<strong>McNab Magento Contact</strong>' and click on the link for <strong>www.mcnab.co/contact/</strong>‎ and the whole shebang is available at the bottom of the page. I've left it up there to demonstrate;</p> <p><img src="https://i.stack.imgur.com/WfeCQ.jpg" alt="enter image description here"></p> <p><strong>Question</strong></p> <p>I am completely confused by this. If I can't reliably use <code>HTTP_REFERER</code> to establish whether the user has arrived from Google, how should I be handling this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload