Check if user agent is GoogleBot

In this post i will provide an example in php how to check if the request is made by Google search engine, typicily each browser have its own signature for example Mozila ,Explorer,Safari we are capable of reaing the user agent information from server variable called HTTP_USER_AGENT ,  Google search bots are identified with speicial UserAgent named Googlebot here is an example for a code that check the user Agent


if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Googlebot' ) !== false )


// paste your email address here

$my_email = '';

// notify via email

mail($my_email,'[Notification]Googlebot Visit', 'Googlebot has just visited your website WEBSITE_NAME: '.$_SERVER['REQUEST_URI']);




echo ("<!– Regular user not google –>");


תגים: , , ,

הפוסט הזה סגור לתגובות כרגע.