If you are a SEO professional one of the many parts of your job is actually measuring your success. Ok so your client is ranked on the first page of 'Maryland Personal Injury Lawyer' now, but what were they ranked when you started? What I do whenever I begin working with a new client is to take all their keyword phrases and see what their current position is. Then on a weekly basis I will run that report again and see our progress. How do we do this? Well we don't manually search Google fo reach keyword instead we use a great little program to do the work for us. Lets take a look
The major problem with finding out our Google ranking on our keywords is that Google really doesn't give us an easy way to do this anymore. Once apon a time Google had a great SOAP API that would allow us to query Google directly from Perl and return the results easily. In fact that is exactly what my program does. Unfortunately Google has stopped issuing SOAP API keys. Why? Well instead they have an AJAX API but it doesn't come close to offering the same functionality. The only other method would be to scrape Google which is a bad thing. Scraping is when you write a program to literally act like a web browser and interact with a web site, get your data and do what you need to do with it. Sounds great. Well it is - it really is. However this is against Google's terms, and I'm just not up for going against Google. So for the purpose of this program we'll assume you have a Google SOAP API key.
The goal of giving out this source code is really two fold. First of all if you have a SOAP API key this is a great small program to help you track your rankings. Secondly its a great opportunity to learn Perl. I'll do more posts on Perl and programming and all that good stuff later, for now lets take a look at the program itself.
This program assumes:
You have Perl installed
You have the Net::Google Module installed (download it here)
The Source Code
use HTML::Parser ();
use Net::Google;
$domainname = $ARGV[0] ;
$filenameis = $ARGV[1];
use constant GOOGLE_LICENSE_KEY => 'YOURAPIKEY';
use constant MAX_RESULTS => 50;
$domain = $domainname;
open(FILE, $filenameis) || die("Could not open file!");
@content=<FILE>;
my $search = $google->search();
$search->max_results( MAX_RESULTS );
Runs the query against the keyword phrase (variable $line);
my $position = 1;
This printf $line will print out the keyword phrase we are searching for.
The results are now cycled through a 'for' loop and stored into the $url variable.
my $url = $result->
URL();
This next line searches through the URL of the result and looks for our domain, if found it prints out the position. If not it adds one to the position counter and checks the next URL result. It'll do this up to 50 results then go to the next keyword.
printf "%3d \n", $position;
}
$position++;
}
}
So as you can see its a pretty simple script. Hopefully I explained that well enough. If you have any questions please shoot me an email or leave a comment. Thanks!
Download source code for this script
This will run the program and search for millerandzois.com and use all the keywords found in mzkeywords.txt.
Windows
If you use Windows its the same but you have to start Perl first so for example
That's it for now I know I'm assuming already you have a lot of things already setup if you don't have those things I promise I will make a post explaining how to setup and use Perl. For those of you not using Perl I highly recommend it. Its very easy to use as shown and can really work well in a bunch of different scenarios.
Stumble It