Doing something different for Search Engine Traffic

Hi,

I want to try and do something a little different for my visitors who come from organic rankings, is there anyway do do something like this:

if ( IS SEARCH ENGINE TRAFFIC) {

Do unique stuff for Search Engine Traffic

}

Is that even possible?

Thanks for any tips

Yes very possible but I’d also head over to the SEO forums and check if there’s a chance you’ll get banned from search engines by providing different content!

You need to check the user agent string, which is supplied in the $_SERVER super global array.

Here’s an example of checking, see below for the source.

$bots = array(
'msn' => 'http://search.msn.com/msnbot.htm', 
'yahoo' => 'http://help.yahoo.com/help/us/ysearch/slurp', 
'WebAlta' = 'http://www.webalta.net/ru/about_webmaster.html'
);
 
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
foreach($bots as $name => $bot)
{
    if(stripos($agent,$bot)!==false)
    {
        echo $name;
    }
}

That script will work for search engines themselves, but I think the topic is about visitors who come from search engines?

If so, you can check the $_SERVER[‘HTTP_REFERER’] value to see if there’s a URL from a search engine in there. HTTP_REFERER is notoriously untrustworthy, though, as it is often unset or can be faked.

I think you missed the point sorry Mal :slight_smile:
Jordash is trying to differentiate between users who arrived via a SERP and those that came some other way. (not cloak by serving different content to search engine bots).

$_SERVER[‘HTTP_REFERER’] is a good solution. It shouldn’t be relied on for security or trusted completely, but for providing a little enhancement for search users it’s fine.
You can test if it contains search engine domains.