5ubliminal@twitter

Estimating Search Volume | Traffic for a Keyword : 5ubliminal's TellinYa

<a href="http://www.tellinya.com/art2/247/">Estimating Search Volume | Traffic for a Keyword : 5ubliminal's TellinYa</a>
Must Reads: Web Scraping | Link Farming | Code Snippets | SEO Freeware » I'm on vacation! … still alive :)
Reveal More!
Before even thinking of using this keep in mind Google's policy against automated queries. This script is for educational purposes only and should not be used to make bulk automated queries.
Estimating search engine traffic!

Any SEO thinks and dreams of just one thing… traffic! But with our given SEO tools estimating it is not the easiest seo task and seo keyword research is rather hard. It's really hard to take a guess on what you can expect if you would rank for a certain keyword in the search engines.

You do have SEO tools such as Google Keyword Estimator, guesswork from Keyword Services such as Wordtracker but all are approximates, way off compared to the real traffic you can get in Google and others.

The traffic estimator from Google does not actually estimate search traffic but clickthrough in ads and the percentage of those who also check out the ads besides the organic serps fluctuates for each type of query.

I kept thinking of how this can be done at least to a certain level. I have an idea of some top traffic keywords and the traffic they can and even comparative analysis can work for me in this. And indeed, I ended up with a quite decent comparative anlysys.

Introducing the Google Trends!

Google Trends is one of the best comparative keyword search volume estimators. It compares up to 5 keyphrases and shows you a graphic with the evolution over a customizable period of time in certain chose locations or worldwide.

Given the fact that the data is mostly graphical it's not so easy to translate it in a human readable format. So I set myself up to find a way to get a text out of the Google Trends so I can do traffic estimation better. By knowing one word I can extrapolate an idea for others.

The solution!

I actually came up with two solutions but I will just share one with you. First, the unshared solution, analyzes the actual image and traces the lines inside and records their evolution based on the color of each element assigned by Google Trends. Makes some averages and gives me a nice report which eventually, in short form, is cut down to the second solution.

Second solution will work easier. Will fetch the Trends page and load the info from it. By info I mean the keyphrase search volume bars shown at the bottom. And it fetches it for all displayed countries and cities and so on.

The Search Volume Estimator PHP Script!

This article relies on the cUrl and PHP class provided on site.

<?
function fetchGoogleFrends($keywords,$date="all"){
    if(!
is_array($keywords)){
        
$keywords=preg_split("/[;,]+/",$keywords);
    }
    if(
count($keywords)>5) return false;
    
$hc=new eHttpClient();
    
$html=$hc->get(
        
"http://www.google.com/trends?q=".
        
urlencode(implode(",",$keywords))."&date=".$date.
        
"&geo=all&graph=weekly_img&ctab=0&sa=N"
    
);
    if(!
preg_match("/<div id=legend>(.*?)<\/div>/si",$html,$keywordLegend)){
        return 
false;
    }
    
$keywordLegend    =$keywordLegend[1];
    if(!
preg_match_all("/<font size=-1 color=#?([^>]+)>([^<]+)<\/font>/is",
            
$keywordLegend,$keywordsColors))
        return 
false;
    
$keywordsColors    =array_combine($keywordsColors[1],$keywordsColors[2]);
    if(!
preg_match_all(
        
"/<td align=left valign=top style='padding: 3 3 5 3'>(.*?)<\/td>".
        
"<td valign=top style='padding: 6 3 5 3'>(.*?)<\/td>/si",$html,$pcs)
    ){
        return 
false;
    }
    
$names $pcs[1];
    
$datas $pcs[2];
    foreach(
$datas as $key => $data){
        if(!
preg_match_all(
            
"/<table class=bar cellspacing=0 width=([0-9]+) height=4>".
            
"<td bgcolor=([^>]+)><\/table>/s",$data,$pcs)
        ){
            continue;
        }
        
$datas[$key] = array_combine($pcs[2],$pcs[1]);
    }
    
$results = array();
    foreach(
$names as $key => $name){
        
$newdatas = array();
        foreach(
$datas[$key] as $dkey => $dval){
            
$newdatas[$keywordsColors[$dkey]] = $dval;
        }
        
$results[strip_tags($name)] = $newdatas;
    }
    return 
$results;
}
//--- This is how U use it!
print_r(fetchGoogleFrends("equity,insurance,loan,mortgage,casino"));
?>

How the script works!

It uses regexp to expose as an array the data search volume data found in Google Trends. Just figure out the countries from the array you need to use. You can also easily alter the script as you need! This script will rank the terms you choose. You need to be aware of traffic on one term to estimate the rest. If one's value is twice the other it has twice the volume and so on. And then imagine the long tail traffic!

Enjoy it and linkback if you like it.

3 Comments Posted By Readers :

Add your comment
#1 Paul Drago from United States
Posted on Tuesday, 18 December, 2007
Hmm...

I wonder if you could this as a basis to start storing Google Trends data into a database which would then alert you say...2 months before any major shift in traffic. (Say 2 standard deviations in traffic levels for keyterms with above X traffic) which would give you time (or it could be an automated process) to build out a site related to that keyword-- get the bad boy indexed and keep moving.
#2 5ubliminal web
Posted on Tuesday, 18 December, 2007
Traffic trends are unpredicatable. If it goes up now id doesn't mean it's going upper tomorrow.
This is best used when picking keywords. You can see which have more potential then others and then decide what your sites will be about.

But you can notice overall trends like summer traffic, holiday traffic and so on and if you plan to sell christmas stuff you can see what to expect.
#3 Paul Drago from United States
Posted on Tuesday, 18 December, 2007
I agree. I was just thinking aloud about possible other uses for the google trend data-- or other ways to implement it in solutions.
Post Feedback 
Name *
Mail *
URL
« Anti-Spam
» URL will only go live after a review. Comments are moderated. «
5ubliminal's TellinYa.com SEM & SEO Blog © 2007 - All rights reserved unless mentioned otherwise .
Rendered On : [Thursday, 21 August, 2008 - 21:00:24 GMT]   No Ajax / Flash Used Here
" Estimating Search Volume | Traffic for a Keyword : 5ubliminal's TellinYa "