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.");
                }
        }
}
-- 
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To post to this group, send email to adwords-...@googlegroups.com.
To unsubscribe from this group, send email to 
adwords-api+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/adwords-api?hl=en.


Reply via email to