Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies


keyword referrals

5:22 pm on Oct 31, 2010 (gmt 0)

New User

5+ Year Member

joined:Oct 31, 2010
posts: 11
votes: 0

Is the keyword a user uses to find a web site through a search engine accessible in any way?

In my site statistics, there is a list of keywords that users have used to find my site through varous search engines so obviously the keywords are getting passed to the server. I was just wondering if they were accessible in some kind of variable? I use php.

Im thinking along the lines of if a user visits my page using keyword 'blue widgets' then a blue widget image is displayed, if the keyword they use is 'red widgets' then a red widget image is displayed instead, is this possible?

10:44 am on Nov 3, 2010 (gmt 0)

Senior Member

joined:Jan 27, 2003
votes: 0

Hi shadowlight, you certainly can access this information. The URL of the user's previous page is contained in the $_SERVER['HTTP_REFERER'] predefined variable [php.net].

You then need to extract the keyword from the search engine's URL, e.g. for Google:


You can use various methods to grab this info - one would be to split the string based on the question mark and & symbols (if they exist) or you could use a regular expression.