I'm using the Ruby API to access the TargetingIdeaService and getting some 
peculiar results. The aim of the program I'm trying to write is to take a 
very large database of keywords (we're talking millons) and, using Hadoop 
MapReduce, query each and every keyword to get the following information:

  - Ad share
  - Competition
  - Search share
  - Search volume

I've written a wrapper around the Ruby client library to make it a little 
easier to use for this purpose. Typical calls look like this:

  AskKeywordIdeas::Api.stats ["car insurance"]
  AskKeywordIdeas::Api.stats ["car insurance"], location: "US"

And they build up a TargetingIdeaServiceSelector using Ruby hashes and 
arrays under the hood, creating a format that the Ruby client library will 
accept. It then uses the "get" method to look for keyword STATS, not IDEAS. 
Also, results are processed to be returned in a more idiomatic Ruby 
fashion. Here's what a typical result looks like:
 

{"car insurance"=>
  {:targeted_monthly_searches=>
    [{:year=>2012, :month=>7},
     {:year=>2012, :month=>6, :count=>673000},
     {:year=>2012, :month=>5, :count=>673000},
     {:year=>2012, :month=>4, :count=>673000},
     {:year=>2012, :month=>3, :count=>673000},
     {:year=>2012, :month=>2, :count=>823000},
     {:year=>2012, :month=>1, :count=>823000},
     {:year=>2011, :month=>12, :count=>550000},
     {:year=>2011, :month=>11, :count=>673000},
     {:year=>2011, :month=>10, :count=>823000},
     {:year=>2011, :month=>9, :count=>823000},
     {:year=>2011, :month=>8, :count=>823000}],
   :extracted_from_webpage=>nil,
   :category_products_and_services=>[10012, 11854, 10550, 10102],
   :search_share=>nil,
   :idea_type=>"KEYWORD",
   :ngram_group=>nil,
   :search_volume=>1000000,
   :ad_share=>nil,
   :competition=>0.976}}


So if you send an array with multiple keywords in it, you will get a hash 
indexed by the keyword in return (which makes it far easier to process on 
our end).

The first problem is that sometimes some data isn't returned. In the above 
example you'll notice that ad_share and search_share are both nil. This 
means that no value was sent back from the API. I'm curious as to why this 
is? For some keywords, none of the four desired fields are returned at all. 
An example of this is "price comparison broad band". The result hash for 
that looks like this:

{"price comparison broad band"=>
  {:targeted_monthly_searches=>
    [{:year=>2012, :month=>7},
     {:year=>2012, :month=>6},
     {:year=>2012, :month=>5},
     {:year=>2012, :month=>4},
     {:year=>2012, :month=>3},
     {:year=>2012, :month=>2},
     {:year=>2012, :month=>1},
     {:year=>2011, :month=>12},
     {:year=>2011, :month=>11},
     {:year=>2011, :month=>10},
     {:year=>2011, :month=>9},
     {:year=>2011, :month=>8}],
   :extracted_from_webpage=>nil,
   :category_products_and_services=>nil,
   :search_share=>nil,
   :idea_type=>"KEYWORD",
   :ngram_group=>nil,
   :search_volume=>nil,
   :ad_share=>nil,
   :competition=>nil}}


How come this happens?

My second query is to do with location search. The example I'm going to use 
is a Portugese one. The keyword: "capitulos de mascaras" returns the 
following hash when queried without specifying a location:

{"capitulos de mascaras"=>
  {:targeted_monthly_searches=>
    [{:year=>2012, :month=>7},
     {:year=>2012, :month=>6, :count=>480},
     {:year=>2012, :month=>5, :count=>480},
     {:year=>2012, :month=>4, :count=>320},
     {:year=>2012, :month=>3, :count=>0},
     {:year=>2012, :month=>2},
     {:year=>2012, :month=>1},
     {:year=>2011, :month=>12},
     {:year=>2011, :month=>11},
     {:year=>2011, :month=>10},
     {:year=>2011, :month=>9},
     {:year=>2011, :month=>8}],
   :extracted_from_webpage=>nil,
   :category_products_and_services=>[10047, 10005, 10358, 10061],
   :search_share=>nil,
   :idea_type=>"KEYWORD",
   :ngram_group=>nil,
   :search_volume=>140,
   :ad_share=>nil,
   :competition=>0.008}}


However, when a location is included like so:

  AskKeywordIdeas::Api.stats ["capitulos de mascaras"], location: "PT"

Which under the hood translates that to this search parameter:

{
  :xsi_type => "LocationSearchParameter",
  :locations => [{ :id => '2620' }]
}


And I have double checked that this is both correct and exactly is what is 
fed into the Ruby client library. The following hash is returned:

{"capitulos de mascaras"=>
  {:targeted_monthly_searches=>
    [{:year=>2012, :month=>7},
     {:year=>2012, :month=>6},
     {:year=>2012, :month=>5},
     {:year=>2012, :month=>4},
     {:year=>2012, :month=>3},
     {:year=>2012, :month=>2},
     {:year=>2012, :month=>1},
     {:year=>2011, :month=>12},
     {:year=>2011, :month=>11},
     {:year=>2011, :month=>10},
     {:year=>2011, :month=>9},
     {:year=>2011, :month=>8}],
   :extracted_from_webpage=>nil,
   :category_products_and_services=>[10047, 10005, 10358, 10061],
   :search_share=>nil,
   :idea_type=>"KEYWORD",
   :ngram_group=>nil,
   :search_volume=>nil,
   :ad_share=>nil,
   :competition=>nil}} 


One would expect a Portugese phrase to have not-nil competition and other 
values when searched with the Portugal location. Furthermore, when using a 
LanguageSearchParameter specifying the correct code for Portugal, the 
following hash is returned:

{"capitulos de mascaras"=>
  {:targeted_monthly_searches=>
    [{:year=>2012, :month=>7},
     {:year=>2012, :month=>6, :count=>480},
     {:year=>2012, :month=>5, :count=>480},
     {:year=>2012, :month=>4, :count=>320},
     {:year=>2012, :month=>3, :count=>0},
     {:year=>2012, :month=>2},
     {:year=>2012, :month=>1},
     {:year=>2011, :month=>12},
     {:year=>2011, :month=>11},
     {:year=>2011, :month=>10},
     {:year=>2011, :month=>9},
     {:year=>2011, :month=>8}],
   :extracted_from_webpage=>nil,
   :category_products_and_services=>[10047, 10005, 10358, 10061],
   :search_share=>nil,
   :idea_type=>"KEYWORD",
   :ngram_group=>nil,
   :search_volume=>140,
   :ad_share=>nil,
   :competition=>0.008}} 


Which looks more or less the same as the hash that returned from the query 
that didn't specify either a language or a location. So my question is what 
am I doing wrong? Also, does Google do language detection for me? It would 
appear that it does but it would be nice to have that confirmed one way or 
the other.

Sorry for all the hashes and things but I've been puzzling over this for a 
while and want to be as clear as possible :)

Thanks,
Sam. 

PS: All of these are examples are from API calls made with production 
details and should, in theory, be reproducible (unless the account the 
query came from makes a difference?).

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en

Reply via email to