Question

Can I detect, using PHP, which keywords a user used to come, from Google SERPs, on a page and based on those keywords display a different title?

I have 2 keywords (e.g. "links" and "bold") on my landing page:

  • When the user comes on the page searching for "links" display title #1.
  • Whenever he comes with "bold" display title #2.
Was it helpful?

Solution

You can read out the referer (the site you were redirected from) with

$_SERVER['HTTP_REFERER']

with that information you can easily parse the URL and decide which title you want.

Possible return value for a user redirected to you through a google search:

https://www.google.com/search?q=bold+link

OTHER TIPS

As others have stated, you can look at the referrer header. *However *, when a user reaches your website from the HTTPS version of Google, the referrer will not include the search term. So, just make sure your site behaves well when you don't have that information.

There are a few jquery plugins that can help you here... The nice thing is that most of them handle search providers including Google, Bing, Yahoo, etc.

Example : https://github.com/hail2u/jquery.highlight-search-terms

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top