Get an email when the Googlebot comes

DGEC

Of course... if the log files are available.  Not everyone is allowed access to the log files though, don't forget. 

Also some clients might just want to know when new site content is indexed and don't want to see all the other log enties, or they are not very technical, find the log files confusing or the programs like awstats confusing and ugly with poor layout (which it is).

And obviously user-agent detection as well as email creation are php techniques that have other uses.  For those learning PHP in bite-sized chunks, they might find it useful.

spida

Haha, don't you get enough SMS per day yet?  8-)
This code is unnessesary, since your logfile tells you exactly how often which bot visited wich of your project's pages.

Regards,
spida

DGEC

By the way, you can set this up for other visitors as well.

For example, you can modify it to email you if other search engines hit your site, or if ANYBODY hits a special page without waiting to check your sever log statistics.

Take a look at http://www.useragentstring.com/pages/useragentstring.php if you're interested.

DGEC

You get that many hits per day from the bot?  :?  I only get it a few times a day at most, usually every few days.

Or are you confusing the BOT, with people coming to your site because they ran a search on Google?

Waldschwein

Hello!

Well, I have to say - let's see at my awstats - that the Googlebot had only in november 8995 accesses on my page. And you have to say that Googlebot visits you very often, you can say 10-30 times a day. So I would be very, very carefully with this snippet. 
And btw: Why do you know that Googlebot visits you? Google is everywhere...

Regards Michael

DGEC

I found this code various places around the 'net, which emails you whenever the Googlebot is detected, has anyone else tried something like it?  I'm not sure if the mail statement will work or not.

(I thought I first read about it on here, but I can't find any references to it). I'm assuming it works now, an ELSE condition is detected.

if(eregi("googlebot",$_SERVER['HTTP_USER_AGENT'])) {
  mail("your.email@example.com", "Googlebot detected", "Google has crawled : ".$_SERVER['REQUEST_URI']);
}


I threw it in a CODE section to know when specific page is crawled (like home or news page). The original was wrapped in
<?php  ?> so it would work in index.php of course.

If you try it, watch out your browser/editor doesn't "helpfully" convert the quotes to proper opening and closing quotation marks - it was driving me bonkers trying to figure out why I was getting an error!