Tuesday, January 3, 2012

Google web preview bot check PHP

I was faced with problem of google web preview "bot".
Its really not a bot, but a chrome tool which makes preview of site which you hover in google search.

The problem was that google web preview "bot" sees page without cookies in users PC. that means google bot will see all advertises which should popup for new coming user.

So solution for this is to check who is looks at page and don't show anything if its an google bot preview.

PHP code:

$bot_v = false;  
$uAgent=$_SERVER['HTTP_USER_AGENT']; 
if(strpos($uAgent,"Google Web Preview") > 0) 
{ $bot_v=true; }

No comments:

Post a Comment