Previous Section  < Day Day Up >  Next Section

Hack 34. Measure Google Mindshare

Measure the Google mindshare of a particular person within a query domain.

Based on an idea by author Steven Johnson (, this hack determines the Google mindshare of a person within a particular set of Google queried keywords. What's Willy Wonka's Google mindshare of "Willy"? What percentage of "weatherman" does Al Roker hold? Who has the greater "The Beatles" Google mindshare, Ringo Starr or Paul McCartney? More importantly, what Google mindshare of your industry does your company own?

Google mindshare is calculated as follows. Determine the size of the result set for a keyword or phrase. Determine the result set size for that query along with a particular person. Divide the second by the first and multiply by 100, yielding percent Google mindshare. For example: A query for Willy yields about 2,760,000 results. "Willy Wonka" +Willy finds 133,000. We can conclude—however unscientifically—that Willy Wonka holds roughly a 5% ((133,000 / 2,760,000) x 100 = ~ 4.82) Google mindshare of "Willy."

Sure, it's a little silly, but there's probably a grain of truth in it somewhere.

2.16.1. The Code

Save the following code as a CGI script ["How to Run the Hacks" in the Preface] called google_mindshare.cgi in your web site's cgi-bin directory.


# google_mindshare.cgi

# This implementation by Rael Dornfest,


# Based on an idea by Steven Johnson,



# Your Google API developer's key.

my $google_key='insert key here';


# Location of the GoogleSearch WSDL file.

my $google_wdsl = "./GoogleSearch.wsdl";


use SOAP::Lite;

use CGI qw/:standard *table/;



  header( ),

  start_html("Googleshare Calculator"),

  h1("Googleshare Calculator"),


  'Query: ', br( ), textfield(-name=>'query'),

  p( ),

  'Person: ',br( ), textfield(-name=>'person'),

  p( ),

  submit(-name=>'submit', -value=>'Calculate'),

  end_form( ), p( );


if (param('query') and param('person')) {

  my $google_search  = SOAP::Lite->service("file:$google_wdsl");


  # Query Google for they keyword, keywords, or phrase.

  my $results = $google_search ->


      $google_key, '"'.param('query').'"', 0, 1, "false", "",  "false",

      "", "latin1", "latin1"



  # Save the results for the Query.

  my $query_count = $results->{estimatedTotalResultsCount};


  my $results = $google_search ->


      $google_key, '+"'.param('query').'" +"'.param('person').'"', 0, 1,

      "false", "",  "false", "", "latin1", "latin1"


  # Save the results for the Query AND Person.

  my $query_person_count = $results->{estimatedTotalResultsCount};




      b(sprintf "%s has a %.2f%% googleshare of %s",


        ($query_person_count / $query_count * 100),






print end_html( );

2.16.2. Running the Hack

Visit the CGI script in your browser. Enter a query and a person. The name doesn't necessarily have to be a person's full name. It can be a company, location, just about any proper noun, or anything, actually. Click the Calculate button and enjoy. Figure 2-10 shows the Willy Wonka example.

Figure 2-10. Google mindshare for Willy Wonka

2.16.3. Fun Hack Uses

You can't do too many practical things with this hack, but you can have a lot of fun with it. Playing unlikely percentages is fun; see if you can find a name/word combo that gets a higher percentage than other percentages that you would consider more likely. Here are the answers to the questions posted at the beginning of this hack, and more:

  • Willy Wonka has a 4.82% Google mindshare of "Willy."

  • Al Roker has a 2.47% Google mindshare of "weatherman."

  • Ringo Starr has a 1.55% Google mindshare of "The Beatles."

  • Paul McCartney has a 6.95% Google mindshare of "The Beatles."

  • Red Hat has a 5.08% Google mindshare of "Linux."

  • Microsoft has a 6.87% Google mindshare of "Linux."

    Previous Section  < Day Day Up >  Next Section