65.9K
CodeProject is changing. Read more.
Home

How to be notified if a website is crawled by Google?

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.17/5 (7 votes)

Sep 9, 2006

CPOL

1 min read

viewsIcon

29090

This article explains a code snippet on how to receive a notification when Google hits a website.

Introduction

It was always a question to me how to be notified when a search engine robot like Google's reaches a website. On the other hand, I was wondering about receiving a notification as soon as Google explores my website.

I spent sometime on Google and searched the internet to see if I could find a trick or technique to employ to receive a notification once my website is hit by Google itself. The question is not why it is important to know when a website is crawled by Google, but how to achieve this goal?!

Code Snippet

First of all, please don't expect this article to describe an algorithm or a lengthy sample code. This is only a small but useful technique. I ran into the following PHP code snippet in PHP on a weblog somewhere on the internet:

if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Googlebot' ) !== false )
{
    // The email address we want to send the email to
    $email_address = 'MyName@MyDomain.com';

    mail($emai_address,'Google bot','The website is hit by google now.',
         'from@MyDomain.com');
}

In the body of the above 'if' statement, an email is sent to MyName@MyDomain.com once the website is hit by Google. We can even send a notification to cell phones too if Google reaches a website. All we need is to substitute the code inside the 'if' block with a instructions to trigger an SMS to a cell phone via web, as it is described in this weblog.