Tuesday, March 02, 2010

Google Keyword Competition Script

In addition to web development, I also do my fair share if Internet marketing and Search Engine Optimization consultation. One of the methods at the core of SEO is keyword research. There are plenty of tools out there for doing keyword research - Micro Niche Finder, Keyword Elite, Market Samauri, just to name a few - but I prefer to do it myself using the Google Adwords Keyword Tool (GAKT) and Google search.

I use GAKT to identify likly keywords related to whatever market I'm researching, and I then go straight to Google to check:

Broad competition (total number of results on a search performed without quotes)
Exact competition (total number of results on a search performed with quotes around the keyword)
AllInUrl (allinurl:keyword)
AllInTitle (allintitle:keyword)
AllInAnchor (allinanchor:keyword)
AllInText (allintest:keyword)

These searches bring back numbers that let me evaluate the competetiveness of the keyword - that is how easy it might be to get well ranked in Google's results.

As you can imagine, typing all that is a pain, so just yesterday I wrote a little ASP script that goes out and gets all the info for you:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Google Keyword Competition Stats </TITLE>
<style type="text/css">
body {font: normal 12pt arial}
</style>
<!--
If would be nice if you left in the below, but if you get some sort of savage glee by deleting it, then have at it.
Script by Dave, AKA Wedango on the WarriorForum
ASP blog: http://retrowebdev.blogspot.com/
He also does web sites and stuff: Webdango.com
-->
</HEAD>

<BODY>
Enter Your Keyword
<br><br>
<FORM METHOD=POST ACTION="goog-stats.asp">
<INPUT TYPE="text" NAME="keyword">
<INPUT TYPE="submit">
</FORM>
<%
Dim strKeyword

strKeyword = ""
strKeyword = Trim(Request.form("keyword"))

If strKeyword <> "" Then
Dim objXMLHTTP, strURL, iBroadComp, iExactComp, iAllInURL, iAllInTitle, iAllInAnchor

Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")

Response.write("Results for <b>"&strKeyword&"</b><br><br>")
'broad competition
Response.write("Broad Competition: "& fKeywordStats("broad",strKeyword) &"<br>")

'exact competition
Response.write("Exact Competition: "& fKeywordStats("exact",strKeyword) &"<br>")

'allintitle
Response.write("All In Title: "& fKeywordStats("allintitle",strKeyword) &"<br>")

'allinurl
Response.write("All In URL: "& fKeywordStats("allinurl",strKeyword) &"<br>")

'allinanchor
Response.write("All In Anchor: "& fKeywordStats("allinanchor",strKeyword) &"<br>")

'allincontent
Response.write("All In Text: "& fKeywordStats("allintext",strKeyword) &"<br><br>")

Set objXMLHTTP = nothing
End If
%>

<%
Function fKeywordStats(TheType, TheKeyword)
Dim strURL, strHTML, vStart, vEnd, vLength

vStart = 0
vEnd = 0
vLength = 0

Select Case TheType
Case "broad"
strURL = "http://www.google.com/search?hl=en&q="&strKeyword&""
Case "exact"
strURL = "http://www.google.com/search?hl=en&q="""&strKeyword&""""
Case "allinurl"
strURL = "http://www.google.com/search?hl=en&q=allinurl%3A"&strKeyword&""
Case "allintitle"
strURL = "http://www.google.com/search?hl=en&q=allintitle%3A"&strKeyword&""
Case "allinanchor"
strURL = "http://www.google.com/search?hl=en&q=allinanchor%3A"&strKeyword&""
Case "allintext"
strURL = "http://www.google.com/search?hl=en&q=allintext%3A"&strKeyword&""
End Select

objXMLHTTP.Open "GET", strURL, false
objXMLHTTP.Send
strHTML = objXMLHTTP.responseText

vStart = Instr(strHTML,"</b> of about <b>") + 17
vEnd = Instr(strHTML,"</b> for <b>")
vLength = vEnd - vStart

If vStart > 17 then
strHTML = Mid(strHTML,vStart,vLength)
Else
strHTML = "no results"
End If

fKeywordStats = strHTML
End Function
%>
</BODY>
</HTML>


The script has to be run on a Windows server with the Microsoft.XMLHTTP object enabled.

Name the script goog-stats.asp. If you name it something different, you have to change the name in the FORM ACTION value.

Happy keyword hunting!

2 comments:

Anonymous said...

thanks a lot man, found this blog by accident.. wish you would do some more writing on SEO and marketing..

Anonymous said...

This one is very helpful..
Thank you..