Get notified when Googlebot visits the page
Posted: Thu Feb 28, 2008 10:58 pm
Hi all,
sometimes you just need to know when Googlebot (or any other bot) visits your pages.
In most cases you are interested in a special page - e.g. you might want to know whether the Goog visits your News Overviev regularly or not at all. Wouldn't it be a great idea if the page would simply send you an email when Googlebot visited?
It just takes a simple UDT:
If you want to monitor many pages, put it into the template(s) or into the footer.
Have fun!
Alex
sometimes you just need to know when Googlebot (or any other bot) visits your pages.
In most cases you are interested in a special page - e.g. you might want to know whether the Goog visits your News Overviev regularly or not at all. Wouldn't it be a great idea if the page would simply send you an email when Googlebot visited?
It just takes a simple UDT:
Code: Select all
$ua = $_SERVER["HTTP_USER_AGENT"];
if(eregi("Googlebot",$ua))
{
$server = $_SERVER["SERVER_NAME"];
$filepath = $_SERVER["REQUEST_URI"];
$url = "http://".$server.$filepath;
$today = date("F j, Y, g:i a");
$subject = "Googlebot detected on $server";
$msg = "$today - Google crawled $url";
$to = "me@here.com";
mail("$to", "$subject", "$msg");
}
- - name the UDT as you like, e.g. "botcheck"
- - substitute "Googlebot" with the name (i.e. the string that identifies the bot) of the bot you want to monitor
- - change $to, $msg and $subject to suit
- - put {botcheck} on the page you want to monitor
If you want to monitor many pages, put it into the template(s) or into the footer.
Have fun!
Alex