How to get an email whenever Google visits your site

Do you want to be emailed whenever Google’s spider (GoogleBot) visits your site or your page(s)? If yes, here is an easy way to do it.

I was reading the article - Ever wanted to know when google crawls your site via Digg. The article explains how you to send an email via a PHP Script when Google’s spider (GoogleBot) visits your site. So, why not automate that for each and every page that is PHP powered.

To include the script on every page of your site, let us follow the following steps;

1. Modify your .htaccess file (create if you do not have one) to use the auto_prepend_file feature, it should have this line
php_value auto_prepend_file /home/yourdomain.com/www/html/autoappend.php
(a single line full absolute path to the autoappend.php on your server)
2. Create/Modify your autoappend.php (you are free to change the file name accordingly here and in the .htaccess file) to include the PHP script from swik.net (I’ve modified it slightly to have a clickable url when you get the mail);

<?php //let us notify someone when google crawls this page if ( strpos( $_SERVER['HTTP_USER_AGENT'], ‘Googlebot’ ) !== false ) { // The email address we want to send the email to $email_address = ‘mymail@domain.com’; // Send the email mail($email_address,’Googlebot Visit’, ‘Googlebot has visited your page: http://’.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']); } ?>

But, my files extension is not PHP even though my server support PHP, how do I use this?

Well, you can use the same .htaccess to enable PHP for any file extension, you have to add this line

AddType application/x-httpd-php .html .htm

This will parse all files with the extension html and htm as PHP scripts.

References

Update

  1. 2006 June 5 (10:00 am) - Be careful to set a filter for your email for this one. Now, I’m bombarded with “Googlebot Visit” mails!
  2. 2006 June 5 (02:00 pm) - This is perhaps a bad idea for a high traffic website. So, far I have received over 500 emails in just about 5 hours. I’m turning mine off.


Don't like it? There are lots of published articles, pick a random one.

oCricket

Brajeshwar posted this article on Tue, Jul 4th, 2006 at 6:00 pm
Categorized under Technology and has the following tags

Prev Article: Movable Type 3.3

Next Article: Fabrik opens limited beta account

Archives: Visit the Archives for more articles.

Comments Post Yours

There are one response so far. You can follow any responses to this entry through the RSS feed. You can skip to the end and leave a response. Pinging is currently not allowed.

  1. One thing to watch with this though is that lot’s of spammers, particularly Comment spammers set ‘Googlebot’ to be the user agent so you’ll get a lot of false positives from this I would have thought.

Post yours

Sidenotes

Quick notes, scribbles, somehow related to this website and to what I do. Or perhaps I'm just plain lazy to make them into a full article.

Great Indian Developer Summit 2009

I got a Press Release of the upcoming GIDS '09 and here is an excerpt. The summit's program covers Java, REST, Unit testing, Groovy, Spring, Struts 2.0, SOA, Cloud Computing, Web Services, JRuby, RoR, Ruby, JVM, ...21st Jan, 2009

The flourishing gun market in Pakistan

VICE Travel: Darra, Pakistanby Top-Notch112 (Via: Deep Green Crystals) 20th Jan, 2009

Angry Ringtone for iPhone and others

[audio:http://audio.brajeshwar.com/angry-ring-ring.mp3] The ANGRY RINGTONE for iPhone. (Click the PLAY button above!) Download * iPhone Ringtone (.m4r) * MP3 Ringtone (.mp3) * Zipped (both .m4r and .mp3) To use it as an iPhone Ringtone; just double click the file "angry-ring-ring.m4r" and it ...15th Jan, 2009

IIM Ahmedabad's Leverage 2009

Leverage, the Venture Capital and Private Equity Club of IIM Ahmedabad and the Centre for Innovation Incubation and Entrepreneurship bring to you the 1st edition of the Venture Capital and Private Equity Conference on the ...12th Jan, 2009

Fedora 10 Released

Let's talk history! Fedora was created in late 2003 as a Linux based Operating System which gives the users an admittance from anywhere in the world to the most up-to-date free and open source software ...28th Nov, 2008

View the Sidenotes Archive

Play the Penguin Game

Recommended

  • Not Safe for Work Ever clicked a link and felt embarrassed with the content in front of your co-workers? Ever caught unaware because the funny link your friend sent was a little beyond funny? Let’s minimize that with NSWF.
  • My Special Job My Special Job is a place where you can look for your weird necessities, strangely superb employees, when your need are more of those hackers, geeks, and ultimate rockstars in the Internet Technology.
  • Ode to Apple Dedicated to Apple - Mac, iPhone, iPod, iTunes, Quicktime, Apple TV and all the awesome softwares for the Apple Mac.
  • o! Just Me Of colorful cultures, entertainment, media, life hacks, music, books and movies from hollywood & bollywood.
  • oCricket oCricket is about Cricket and people enthusiastic about it.
  • AS 2.0 Reference Reference for ActionScript 2.0 Programming Language used in Flash. Primarily stashed here for my own personal reference.
  • Forum Oinam’s technical discussion forum where developers and designers can discuss all technical topics.

Download free Brajeshwar Wordpress Theme

Brajeshwar

Brajeshwar I firmly believe in keeping things simple, easy for users and I envison pushing the technical envelop time and again for the betterment of viable commercial and practical applications. More about me.

Brajeshwar's affinity with Adobe

My Photos

More photos on Flickr

Member of 9rules Network

Since its inception on 11th June, 2001, "Brajeshwar" has 949 Articles and 6,472 comments, contained within 22 categories and 1,497 tags.