18

Mar

Show keyword ranking on a web page automagically

Posted by stuart as , , ,

Whilst doing some preparation for my local SEO Rank renting project, I decided if I’m going to try to rent out the pages, it would be nice if potential “tenants” could see just by looking at the page, where it ranked for the keyword it was targeting (without me having to manually update the stats all the time).

Then it occurred to me that this sort of tool might have all sorts of other applications, as part of bigger projects.

So anyhoo, I knocked up this little script, all you need to do is edit the $keyword variable at the top of the script, then paste it in your web page where you’d like the ranking info to show.

You can see this script in action here, on the right hand side of the screen.

When I get the chance, I’ll update the script to allow you to check the ranking for multiple keywords on a single page.

So here it is: have fun!

<?

//Enter Your Keyword Here!

$keyword = “Whatever Keyword You Are Targeting For The Page“;

$search = strtolower($keyword);

$search = str_replace(” “, “+”, $search);

//Get the current URL so we can compare it to the search results

$url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
//Do the google search thing, get the top 100 results for our keyphrase

$data = file_get_contents(’http://www.google.com/search?q=’ .$search. ‘&num=100′ );

$description= (’/<div class=g><h2 class=r><a href=\”(.+?)\” class=l/’);

preg_match_all($description,$data,$match);
echo ‘Google keyword rankings for this page<br>’;

//start counting, and work out what our ranking is

$count = 0;

foreach($match[1] as $value){

$count = $count+1;

//get the ranking and print to screen

if (stristr($value, $url)) {

echo $keyword. ‘: <a href=”http://www.google.com/search?q=’ .$keyword. ‘&num=100″>’ .$count. ‘</a>’;

}

}

?>

That is all!

9 comments so far

How much are you planning on renting each site for…? Obviously it depends on niches and whatnot but I’m curious.

Hi Brandon,

I’m in a city of around 1.3 million people, so obviously not as much as you could get in New York or London, but I think I’d be aiming at averageing somewhere between $50 and $100 per page per year.

I think what I’ll do is go into my AdWords account, look at what I’d be paying for top spot for a geotargeted Adwords ad aimed at my locality, and work out some sort of formula to base my pricing on.

Long way to go before I get there yet, I’m just trying to get my head around the usability and architecture of a site like this.

There’s lots of cool stuff you could include in a site like this: Google Maps, Flickr photos, news feeds etc etc. (I’m not a big one for actually writing content - especially 200 to 300 pages of it! ;-) )

Stay tuned! :-)

Very useful little script, thanks for sharing!

Thanks for sharing this script to us! Have you try this already?

Thanks for sharing. I am dutch and I use google.nl.
I have tried the script with:
…http://www.google.nl/search?..
and it works!

That script is pretty cool. Thanks for sharing. I am creating my new blog with a Brian Gardner theme and will incorpaorate that into it. Thanks again.

I recently came accross your blog and have been reading along. I thought I would leave my first comment. I dont know what to say except that I have enjoyed reading. Nice blog.

great blog, very interesting information.

Thanks for the script. I will try it out.

Leave a Comment:

Name (required)
Mail (will not be published) (required)
Website
Message