Creating a Location Hierarchy Using LocationCriterionService

627 views
Skip to first unread message

Jeremy Tremblay

unread,
Apr 30, 2014, 12:13:32 PM4/30/14
to adwor...@googlegroups.com
According to the documentation here : https://developers.google.com/adwords/api/docs/guides/location-targeting

"LocationCriterionService allows you to request the parent locations for a location. This is done by adding ParentLocations to the list of selector fields. For example, our previous code returned the location (Quebec city) as well as its parent location (Canada). This feature is useful if you want to display a hierarchical list of locations to your customers, or if you want to add inclusion or exclusion logic for geo locations while targeting your campaigns."

Yet from the examples, this only looks to be possible if we start towards the bottom of the location hierarchy and work our way up. I would however like to display a selectable list of US locations based on state. That is a user would select a US state and from there a list of child locations would be displayed for them to choose from. I intend to use this location in a TargetingIdeaServiceInterface search, so I need the exact id or LocationName to pass to the search. 

I can't seem to find a programmatic way to discover the child Locations of a particular Location. I've attempted to search for all Locations that have a particular ParentLocation, but ParentLocations is not an acceptable Predicate. I understand that I could persist the  targets table data in a database to do this, but this would require me to keep abreast of updates so I would prefer the dynamic approach. 

I'll bet I'm missing something, and this approach is possible. Any ideas? 

Ray Tsang (AdWords API Team)

unread,
May 1, 2014, 1:50:08 PM5/1/14
to adwor...@googlegroups.com
Jeremy,

Your observations are spot on.  The service cannot use ParentLocation as a predicate.  You will need to use the CSV file to seed your data set and updating it using the data from the service.

Thanks,

Ray

Jeremy Tremblay

unread,
May 2, 2014, 4:38:13 PM5/2/14
to adwor...@googlegroups.com
Ray, 

Thanks so much for your prompt reply. I was hoping I was wrong... Are there any plans to provide that sort of search functionality in the future? Or is it perhaps intentionally excluded to reduce API traffic?

How would I go about updating my data set using the service? I can see how I might be able to update the Status property of geographical locations that I already have in my data set, but how would I know if a new one were added? Is there a mechanism for notification when a new data set is released in its entirety (i.e. the latest was released 2014-04-07)? 

Thanks again,

-jt-

Ray Tsang (AdWords API Team)

unread,
May 6, 2014, 11:39:32 AM5/6/14
to adwor...@googlegroups.com
Jeremy,

I've added a feature request.  We don't have active notifications at the moment, please check for updates on the Geographical Targets page.

Thanks,

Ray

Jeremy Tremblay

unread,
May 6, 2014, 4:19:29 PM5/6/14
to adwor...@googlegroups.com
Great Ray. Thanks again for your help!

cv

unread,
Jun 17, 2017, 6:41:30 AM6/17/17
to AdWords API Forum
Hello Ray,

I have also noticed that I can select or exclude available locations based on map while creating new campaign in Adwords UI.

So, My question is should I get Nearby locations names or city names based on radius or based on proximity to include or exclude GEO while creating campaign through API?

Thanks,

Shwetha Vastrad (AdWords API Team)

unread,
Jun 26, 2017, 12:55:36 PM6/26/17
to AdWords API Forum
Hi, 

You can follow this guide to setup location targeting using AdWords API. If you would like to target specific locations, you need to create a Location object with an appropriate code to target a region. You can use the LocationCriterionService to look up the criterion ID for a location. If you like to target within the proximity of a location, you need to create a create a Proximity object and specify a lat/long pair or use the address fields which will be geocoded into a lat/long pair. The AddCampaignTargetingCriteria Java example shows how to add different types of targeting criteria to a campaign. The LookupLocation Java example shows how to use LocationCriterionService to look up location criterion codes. Example code in other languages is provided here.

Regards,
Shwetha, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages