Author Topic: Get an email when the Googlebot comes  (Read 3945 times)

Offline DGEC

  • Posts: 388
  • Gender: Male
    • EbelTech homepage
Get an email when the Googlebot comes
« on: November 30, 2007, 08:10:18 PM »
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.

Code: [Select]
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!


Waldschwein

  • Guest
Re: Get an email when the Googlebot comes
« Reply #1 on: December 01, 2007, 11:30:13 AM »
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
 

Offline DGEC

  • Posts: 388
  • Gender: Male
    • EbelTech homepage
Re: Get an email when the Googlebot comes
« Reply #2 on: December 04, 2007, 08:21:48 PM »
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?

Offline DGEC

  • Posts: 388
  • Gender: Male
    • EbelTech homepage
Re: Get an email when the Googlebot comes
« Reply #3 on: February 08, 2008, 08:07:00 PM »
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.

Offline spida

  • Posts: 203
Re: Get an email when the Googlebot comes
« Reply #4 on: April 07, 2008, 01:58:12 PM »
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

Offline DGEC

  • Posts: 388
  • Gender: Male
    • EbelTech homepage
Re: Get an email when the Googlebot comes
« Reply #5 on: April 10, 2008, 01:53:18 AM »
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.

 

postern-length