I have yet to see anyone replying to all the valid questions and frustrations posted in this forum. After MUCH trial and error, here is how to filter by country. This example show global searches and searches within the US. //----------------------------------- // Credentials $user = new AdWordsUser(); // Get the TargetingIdeaService. $targetingIdeaService = $user->GetTargetingIdeaService('v200909'); // Set keyword to retrieve related keywords for. $keyword = new Keyword('termites', 'EXACT'); // Set language. $language = new LanguageTarget('en'); // Set country. $country = new CountryTarget('US'); // Create selector to get related keywords. $selector = new TargetingIdeaSelector(); $selector->requestType = 'STATS'; $selector->ideaType = 'KEYWORD'; $selector->searchParameters = array( new RelatedToKeywordSearchParameter(array($keyword)), new KeywordMatchTypeSearchParameter($keyword->matchType), new LanguageTargetSearchParameter(array($language)), new CountryTargetSearchParameter(array($country)) ); $selector->requestedAttributeTypes = array( 'KEYWORD', 'AVERAGE_TARGETED_MONTHLY_SEARCHES', 'GLOBAL_MONTHLY_SEARCHES' ); // Increase paging for more results. $selector->paging = new Paging(0, 6); // Get targeting ideas. $page = $targetingIdeaService->get($selector); //-----------------------------------
On Mar 2, 10:56 pm, slloyd <steve.ll...@gmail.com> wrote: > How do I filter AVERAGE_TARGETED_MONTHLY_SEARCHES by postalCode or > countryCode? I have the code below and it returns but I am not sure > how to filter it by postalCode or countryCode. Please help. > > <code> > // Credentials > $user = new AdWordsUser(); > // Get the TargetingIdeaService. > $targetingIdeaService = $user->GetTargetingIdeaService('v200909'); > // Keyword > $keyword = new Keyword(); > $keyword->text = 'termites'; > $keyword->matchType = 'EXACT'; > > // Create selector. > $selector = new TargetingIdeaSelector(); > $selector->requestType = 'STATS'; > $selector->ideaType = 'KEYWORD'; > //$selector->localeCode = 'en_US'; > //$selector->countryCode = 'US'; > //$selector->postalCode = '84062'; > $selector->requestedAttributeTypes = array( > 'KEYWORD', > 'AVERAGE_TARGETED_MONTHLY_SEARCHES', > 'GLOBAL_MONTHLY_SEARCHES' > ); > > // Set selector paging (required for targeting idea service). > $paging = new Paging(); > $paging->startIndex = 0; > $paging->numberResults = 1; > $selector->paging = $paging; > // Create related to keyword search parameter. > $relatedToKeywordSearchParameter = new > RelatedToKeywordSearchParameter(); > $relatedToKeywordSearchParameter->keywords = array($keyword); > $selector->searchParameters = > array($relatedToKeywordSearchParameter); > // Get related keywords. > $page = $targetingIdeaService->get($selector); > </code> -- 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.