using TargetingIdeaService for EXACT match stats

252 views
Skip to first unread message

v

unread,
Jan 12, 2010, 6:58:41 PM1/12/10
to AdWords API Forum
Hello,

I am using TargetingIdeaService to find the following stats about a
keyword:
local search volume, global monthly search volume, search volume
trends, highest volume occurred in.

I have the code below working but I am not sure what API call I need
to use to get "local search volume". When I looked up online, it seems
KeywordVariation.getLastMonthSearchVolume is equivalent to "local
search volume", but for that I have to use KeywordToolService ad I
would rather stick to TargetingIdeaService as I am using the latest
version of adwords api(v2009) . I also noticed that data related to
"AVERAGE_TARGETED_MONTHLY_SEARCHES" never comes back. Any ideas?

Thanks in advance,

CODE:


public class GetRelatedKeywords {
private static final String email = "......";
private static final String password = "......";
// private static final String clientEmail = "......";
private static final String useragent = "......";
private static final String developerToken = "......";
private static final String applicationToken = "......";

private static final String namespace = "https://adwords.google.com/
api/adwords/v13";

public static void main(String[] args) throws Exception {
// Log SOAP XML request and response.
AdWordsServiceLogger.log();


AdWordsUser user = new AdWordsUser(email, password, useragent,
developerToken, applicationToken);

// Get the TargetingIdeaService.
TargetingIdeaServiceInterface targetingIdeaService = user
.getService(AdWordsService.V200909.TARGETING_IDEA_SERVICE,
"https://adwords-sandbox.google.com/api/adwords/o/v200909/
TargetingIdeaService");


Keyword[] kwa = new Keyword[1];
kwa[0] = new Keyword();
kwa[0].setText("cheap airline tickets");
kwa[0].setMatchType(KeywordMatchType.EXACT);

LanguageTarget lt = new LanguageTarget();
lt.setLanguageCode("en");
CountryTarget ct = new CountryTarget();
ct.setCountryCode("US");

// Create selector.
TargetingIdeaSelector selector = new TargetingIdeaSelector();
selector.setRequestType(RequestType.STATS);
selector.setIdeaType(IdeaType.KEYWORD);
selector.setLocaleCode("en_US");
selector.setRequestedAttributeTypes(new AttributeType[] {
AttributeType.KEYWORD, AttributeType.COMPETITION,
AttributeType.TARGETED_MONTHLY_SEARCHES,
AttributeType.AVERAGE_TARGETED_MONTHLY_SEARCHES,
AttributeType.GLOBAL_MONTHLY_SEARCHES });

// Set selector paging (required for targeting idea serivce).
Paging paging = new Paging();
paging.setStartIndex(0);
paging.setNumberResults(1);
selector.setPaging(paging);

// Create related to keyword search parameter.
RelatedToKeywordSearchParameter relatedToKeywordSearchParameter =
new RelatedToKeywordSearchParameter();
relatedToKeywordSearchParameter.setKeywords(kwa);
selector.setSearchParameters(new SearchParameter[] {
relatedToKeywordSearchParameter,
new LanguageTargetSearchParameter(null,
new LanguageTarget[] { lt }),
new CountryTargetSearchParameter(null,
new CountryTarget[] { ct }) });

// Get related keywords.
TargetingIdeaPage page = targetingIdeaService.get(selector);

// Display related keywords.
if (page.getEntries() != null && page.getEntries().length > 0) {
for (TargetingIdea targetingIdea : page.getEntries()) {
Type_AttributeMapEntry[] data = targetingIdea.getData();
for (int i = 0; i < data.length; i++) {
System.out.println(data[i].getKey());
if (data[i].getKey().equals(
AttributeType.TARGETED_MONTHLY_SEARCHES)) {


MonthlySearchVolume[] msvs = ((MonthlySearchVolumeAttribute) data
[i]
.getValue()).getValue();
for (MonthlySearchVolume msv : msvs) {

System.out.println(msv.getMonth());
System.out.println(msv.getYear());
System.out.println(msv.getCount());
}
} else if (data[i].getKey().equals(
AttributeType.GLOBAL_MONTHLY_SEARCHES)) {

System.out.println(((LongAttribute) data[i].getValue())
.getValue());
} else if (data[i].getKey().equals(
AttributeType.COMPETITION)) {

System.out.println(((DoubleAttribute) data[i]
.getValue()).getValue());
} else if (data[i].getKey().equals(
AttributeType.AVERAGE_TARGETED_MONTHLY_SEARCHES)) {

System.out.println(((DoubleAttribute) data[i]
.getValue()).getValue());
} else if (data[i].getKey().equals(AttributeType.KEYWORD))
{
System.out.println(((KeywordAttribute) data[i]
.getValue()).getValue().getText());
System.out.println(((KeywordAttribute) data[i]
.getValue()).getValue().getMatchType());
}
}

}
} else {
System.out.println("No related keywords were found.");
}
}
}

AdWords API Advisor

unread,
Jan 14, 2010, 6:02:03 PM1/14/10
to AdWords API Forum
Hi,

Certain data isn't returned in the sandbox, and all the data that is
returned is dummy data. Local search volume is returned as
TARGETED_MONTHLY_SEARCHES, which uses the country and language targets
you specify.

Best,
- Eric Koleda, AdWords API Team

v

unread,
Jan 19, 2010, 4:32:14 PM1/19/10
to AdWords API Forum
Thanks for the response. I noticed that in the api it is mentioned
that "get" method returns a page of ideas that match the query
described by the specified TargetingIdeaSelector. The selector must
specify a Paging value, with numberResults set to 800 or less. If I
need to get stats for 4000 keywords, then my understanding is that I
need to make 5 calls by calling setStartIndex() and setNumberResults()
with different values in each call? To be precise those 5 calls to get
() method would be made with following values set on Paging object,
setStartIndex(0) and setNumberResults(800)
setStartIndex(801) and setNumberResults(1600)
setStartIndex(1601) and setNumberResults(2400)
setStartIndex(2401) and setNumberResults(3200)
setStartIndex(3201) and setNumberResults(4000).

Please correct me if I am wrong.

Thanks,


On Jan 14, 4:02 pm, AdWords API Advisor <adwordsapiadvi...@google.com>
wrote:

Rich Johns

unread,
Jan 19, 2010, 4:42:24 PM1/19/10
to vjtad...@gmail.com, AdWords API Forum
Should'nt the number of results always be 800? In otherwords, start at
index 801, get me the next 800; start at index 1601, get me the next
800, and so on. I would also think that you'd set things up such that
the next start index was the prevIndex+numActuallyReturned. Isn't the
case that most of the time you won't really know how many are out
there, only that you want them all and that you can only grab 800 at a
time? I'm probably sticking my nose in without really looking at this,
but I would hope there's a way to see how many results were actually
returned.

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

--
rp johns

AdWords API Advisor

unread,
Jan 20, 2010, 1:26:46 PM1/20/10
to AdWords API Forum
Hi,

Yes, you would need to make multiple requests, changing the paging
values each time. As Rich pointed out, since the index is 0 based and
the page size remains 800 for each page, the calls would be:

setStartIndex(0) and setNumberResults(800)
setStartIndex(800) and setNumberResults(800)
setStartIndex(1600) and setNumberResults(800)
setStartIndex(2400) and setNumberResults(800)
setStartIndex(3200) and setNumberResults(800)

Also, Rich is correct that you should probably check to see if the
number of results returned in the page was 800 before you request the
next page.

Best,
- Eric

> >> >            ...
>
> read more »

Reply all
Reply to author
Forward
0 new messages