by john on January 10, 2004

[UPDATE] – Version .30 released 02/08/2004

MTGoogleRank is a Movable Type plugin that allows you to programmatically determine the Google Rank of a keyword or phrase. Have a keyword that is special to you that you always want to know where you stand? MTGoogleRank is for you. MtGoogleRank uses the officially sanctioned Google API so you will be completely “street legal” in its use. To see one example of how this could be used I’ve added a simple GoogleRanks widget toward the bottom of my sidebar. I’ve also added it to my search template.

To use simply download GoogleRank.txt rename the file to and place in your Movable Type plugins directory. Then include the tag in your templates and away you go.

You need a Google API key to use this plugin. If you do not have one you can get one for free at MT has a placeholder for this key within it’s configuration. Open your administration screen, click Weblog Configuration then Preferences and about half way down the page you will find the spot for it.

MTGoogleRank includes the following tags:

MTGoogleRank – The main tag – arguments documented below.
MTGoogleRankVersion – Returns the version number of MTGoogleRank.
MTGoogleRankPoweredBy – Returns the phrase “Powered By MTGoogleRank” with a link to my site.

The main MTGoogleRank tag takes one required argument and optionally up to three additional arguments:

query = the actual query to pass to Google. This is a required argument and you will get a rebuild error if you don’t include it.
url = by default MTGoogleRank uses your own weblog’s url as defined within MT to use in the search. You can override this default if you choose.
pages = by default MTGoogleRank only searches through the first page of results in Google. You can override this default if you choose. Take caution when doing so, however, as the Google API is a little slow and scrolling through many pages is going to slow things down significantly.
count = when the count argument is included MTGoogleRank will return the total estimated number of results for the given query. When this argument exists it is assumed you want the count returned – the value you use does not matter.

MTGoogleRank returns either a numeric value representing the GoogleRank calculated or a string formatted like “>#” where # is the number of results searched. So if you passed the argument pages=3 that would actually search through the first 30 results on Google (10 results per page) and if your search string was not found the value “>30″ would be returned. If the count argument is included then the numeric value returned will be equal to the estimated total result set size.

Here are some usage examples:

<MTGoogleRank query=”rubber chicken”/>
<MTGoogleRank query=”rubber chicken” url=””/>
<MTGoogleRank query=”rubber chicken” url=”” pages=”3″/>
<MTGoogleRank query=”rubber chicken” pages=”3″/>
Out of <MTGoogleRank query=”rubber chicken” count=”true”/> pages on Google, I am in position <MTGoogleRank query=”rubber chicken”/>
<MTGoogleRank query=”” count=”true”/> pages are linked to my site.

Thanks to code from Adam Kalsey MTGoogleRank also supports embedded MT tags, for example:

<MTGoogleRank query=”[MTBlogName]” url=”[MTBlogURL]” pages=”3″/>

Note that instead of using the tag as you would find it in your templates, <$MTBlogName$> you need to use [MTBlogName] with the square brackets.

In a future article I will show you how you can utilize Brad Choate’s MTMacro plugin to include MTGoogleRank results within an entry.

I hope you find it useful. I’d also love to get suggestions for improvement, there should be many.

Tip of the hat to Joe for the inspiration.


* 02/08/2004 – Version .30 released.
** Added MTGoogleRankVersion tag.
** Added MTGoogleRankPoweredBy tag.
** Added code to handle the occasional Google “burp”.
* 01/14/2004 – Version .20 released.
** Added count argument.
* 01/10/2004 – Version .10 released.
** Initial release.


Lisa January 10, 2004 at 4:46 am

I’m a bit confused by this. I really like the idea of reflecting googles pagerank on my site, but I’m a bit flummoxed. When I put query=”” query=”” I only get the number 1 back. So I added pages=”30″ and it stayed at 1, but googles shows 16 pages when I do that in their search.

Can you help a bit more with a specific example of querying for your own sites pageranking? I’m sure I’m just missing something obvious, it is, after all, nearly 6am.

Love the idea for the plugin though, thank you for making it available.

john January 10, 2004 at 5:08 am

Well that’s very interesting, I think what you are looking for is actually a different plugin, an idea I’ll put in front of my head. :-)

What my plugin does is allows you to see where Google ranks your site for a particular keyword or phrase. For example, some people like to Google their name and see where they stand. Using my plugin like this:

<MTGoogleRank query=”lisa” url=”” pages=”10″/>

returns 89. Your site is the 89th Google result for anyone searching “lisa”. Of course if I had done the tag like this:

<MTGoogleRank query=”lisa” pages=”10″/>

which by default uses MY own blog url, it would return “>100″ since I am not ranked on Google for that keyword.

Does that make more sense? Stilll useful?

jayseae January 10, 2004 at 12:34 pm

That’s cool – but can you use embedded MT tags in it? For instance, say I wanted to use it on my “recent comment” list, so people can see where that page ranks at Google. Can I feed your plugin the $MTEntryTitle$, to act as the keywords? If not, might want to look into using/embedding Adam Kalsey’s Expressions plugin ( ), as it would make this mighty useful – just feed some tags and you’re set. Cool idea. Thanks.

john January 11, 2004 at 9:03 am

Thanks for the pointer jayseae. I didn’t think to test it that way. I did test with MTMacro to verify I could post with an entry and what I found was if I included a function from Adam’s MTAmazon macro that I was able to do it. However I just tested with an embedded MT tag and it didn’t work. I will include Kalsey’s Expressions plugin in the next release of MTGoogleRank to allow that functionality. I have a couple of other tweaks I’m going to make once this hits the plugin directory.


john January 11, 2004 at 9:07 am

Actually, I’m wrong. I’ll update the doc. I just looked at and it IS the piece of code I pulled from MTAmazon, I just didn’t realize that the tags needed to be formatted differently.

Joe Grossberg January 12, 2004 at 6:14 pm

Where am I supposed to put the Google API key?

I could hard-code it into your Perl file, but I suspect there’s a more sensible solution.

Joe Grossberg January 12, 2004 at 6:31 pm

Google Rank Tag for Movable Type

I’ve now incorporated my Google rank into the sidebar (below the orange XML button), courtesy of John’s MTGoogleRank plugin. I’d…

john January 12, 2004 at 9:41 pm

Looks like you’ve figured it out Joe, but for the benefit of others there is a spot for it in the MT config – go to Weblog Config, click Preferences link and the spot for Google API is about half way down the page.

distant, early morning: static January 14, 2004 at 10:06 am


col·o·phon ( P ) Pronunciation Key (kl-fn, -fn) n. 1. An inscription placed usually at the end of a book, giving facts about its publication. 2. A publisher’s emblem or trademark placed usually on the title page of a…

MT Plugin Directory January 18, 2004 at 11:42 pm


Joe Grossberg January 19, 2004 at 10:16 am

I have a suggestion for the next version — a way of failing gracefully (e.g. outputting “n/a”) instead of MT choking on the (“500 Internal Server Error at plugins/ line 64″) error.

john January 20, 2004 at 4:47 am

Good point Joe – I don’t know what the issue is there. At first I thought it was simply Google having problems, kind of like how MTAmazon periodically gets hosed up because of some back-end problems at Amazon. But I’ve converted MTGoogleRank to a standalone .pl script and I’ve never once had that error so I’m beginning to think it is related to being called from the plugin. I’ll see what I can do.

john January 23, 2004 at 8:04 pm

I have fixed the problem but of course Google isn’t having problems right now so I can’t tell for sure. The problem was caused because of some flakiness with the Google API that was causing similar problem in MTGoogleSearch. I’ll test it for the next few days and then release the fix once I’m sure it was good.

SEO February 4, 2004 at 9:03 pm

Search Engine and Movable Type Toys

When there is not much news you must cover the fun toys. Spider Hacks teaches you how to create your own spider…which I eventually will. MTGoogleRank shows who how many people link to a site and where a site ranks… February 5, 2004 at 12:11 am

MT Google Rank

MTGoogleRank is a Movable Type plugin that allows you to programmatically determine the Google Rank of a keyword or phrase. Have a keyword that is special to you that you always want to know where you stand? MTGoogleRank is for you. MtGoogleRank uses …

Becky's Journal February 13, 2004 at 12:14 pm

Site updates

Summary of a bunch of site updates I’ve made recently.

diva February 13, 2004 at 10:53 pm

Hi, Joe:
I have started making my blog for only three weeks. I tried to install your MTGoogleRank,
but I failed in rebuilding templates of MT.
The message says “Service description ‘file:/var/home/diva/data/blog/lib/MT/GoogleSearch.wsdl’ can’t be loaded: 501 Protocol scheme ‘file’ is not supported.”
Could I have some suggestion about the trouble?

john February 14, 2004 at 8:01 am

I have not seen that problem.

Does either or give you an idea on the solution?
Let me know.

diva February 14, 2004 at 7:49 pm

Thanks for your quick reply, “John”!
I’m very sorry I wrote to you by mistaken name.

I visited the websites and tried rebuilding as those article said. Unfortunately I failed again.
The massage says:”
Service description ‘’ can’t be loaded: 500 Can’t locate HTML/ in @INC (@INC contains: /var/home/diva/data/blog/extlib /var/home/diva/data/blog/lib /usr/local/lib/perl5/site_perl/5.005/i386-freebsd /usr/local/lib/perl5/site_perl/5.005 . /usr/libdata/perl/5.00503/mach /usr/libdata/perl/5.00503).”
I’m afraid there’s something different concerning with FreeBSD Machine by which my rental server works.

diva February 14, 2004 at 11:39 pm

Thanks for your help.
The rebuild wad finished successfully with no error messages. And then the Main of my MT blog shows a message ‘>10>10>30>30′.
Here’s what I changed below according to the websites you told me;
# my $google_search = SOAP::Lite->service(“file:$google_wdsl”);

my $google_search = SOAP::Lite->service(“”);

See you!

Patrick May 15, 2004 at 6:50 pm

Hi there,

I’ve installed and been playing about a bit with GoogleRank, with intermittent luck. Everything looks good but I’m presently getting an error on rebuild:

An error occurred:

Can’t use an undefined value as an ARRAY reference at plugins/ line 86.

Looking at the code, I’m wondering if it’s possible Google’s not returning ANY result, and therefore the results array is not initialised/null?

Is it possible I’ve used up my 1,000 queries for the day?


Patrick May 16, 2004 at 4:41 pm

Update: It’s the next day and the error above is not occurring. May have something to do with an untrapped Google failure?


Reckless Abandon September 1, 2004 at 4:23 pm

MTGoogleRank and MTYahooRank plugins installed

Well I finished installing MTGoogleRank and MTYahooRank. Both of which are very nifty plugins. All users have access to both of these and information on how to use them can be found on the plugin’s respective page….

0:0:0:0:0:0:0:1 September 2, 2004 at 5:06 am

Major site updates

Where do I start.. Basically I upgraded from MovableType 3.01D to 3.1. This upgrade brougt out quite a few new features such as: Dynamic Pages Scheduled Posting Sub-Categories Application-Level Callbacks I started with sub-categories a few releases ago…

{ 3 trackbacks }

Previous post:

Next post: