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.");
}
}
}
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
Please correct me if I am wrong.
Thanks,
On Jan 14, 4:02 pm, AdWords API Advisor <adwordsapiadvi...@google.com>
wrote:
> --
> 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
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 »