Welcome, Guest. Please login or register.
Did you miss your activation email?
February 12, 2012, 06:08:12 PM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite.
149667 Posts in 21100 Topics by 7538 Members
Latest Member: ionline
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Get an email when the Googlebot comes  (Read 1734 times)
DGEC

Offline Offline

Posts: 386


WWW
« 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:
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!

Logged
Waldschwein
Guest
« 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
 
Logged
DGEC

Offline Offline

Posts: 386


WWW
« Reply #2 on: December 04, 2007, 08:21:48 PM »

You get that many hits per day from the bot?  huh  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?
Logged
DGEC

Offline Offline

Posts: 386


WWW
« 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.
Logged
spida

Offline Offline

Posts: 203


« Reply #4 on: April 07, 2008, 12:58:12 PM »

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

Regards,
spida
Logged
DGEC

Offline Offline

Posts: 386


WWW
« Reply #5 on: April 10, 2008, 12: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.
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!