Check if page comes from Google?

Asked

Viewed 74 times

1

Goodnight

How can I use PHP to find out if the user came from Google and which keyword was typed? So when he registers on my site, I can check where he came from and word who found the site.

Thank you

1 answer

1

You can only check if it came from one of Google’s domains.

A simple example with PHP is to read the global variable $_SERVER['HTTP_REFERER'].

However, it is not possible to get the search terms from the reference URL because the terms are encoded. The coding combines with unique user codes, ie when so-and-so search for "something" will generate a string GVhao390# but if beltran fetch the same word, return a different string 6%U9*8Ed. The key is in the parameter ved.

One of the reasons you encode the terms is because of user privacy issues.

To obtain search reference data, use the Google Webmaster Tools and Google Analytics.

  • Encoded strings are merely illustrative
  • Thank you. But this var comes empty, when I click on my site by Google. Very strange...

  • This is normal. HTTP_REFERER can return empty exponentially. In such cases there is not much to do. But if you always return empty at all, then you may have some problem. In this case check your environment settings (your local machine or your hosting provider).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.