WebsiteBaker Support (2.8.x) > Droplets & Snippets

Get an email when the Googlebot comes

(1/2) > >>

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.


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

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:
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:
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?

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.

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

Navigation

[0] Message Index

[#] Next page

Go to full version