How to set multiple locations or select all country in TargetingIdeaService?

47 views
Skip to first unread message

Mark Anthony Gutierrez

unread,
Apr 2, 2018, 12:08:48 AM4/2/18
to AdWords API Forum
I've been trying to get multiple location or countries in a single request and has not been successful. Here is my code example:

location = [ 2048, 2056, 2680, 2046]
selector['searchParameters'].append({
                'xsi_type': 'LocationSearchParameter',
                'locations': [{'id': location }]
            })

This doesn't work at all.

Peter Oliquino

unread,
Apr 2, 2018, 1:31:08 AM4/2/18
to adwor...@googlegroups.com
Hi Mark,

My apologies if I cannot provide an example using the client library that you are using. However, what I can give you is a description on how you can pass multiple locations into your request. In order to do this, you must first :

1. Create Location objects then set their respective IDs using the Criteria IDs that are available in the geo targeting spreadsheet.
2. Create a List object for your Locations and add each of your Location objects into that List object.
3. You may then pass the list of locations into your LocationSearchParameter using its setLocations() method.

As for targeting all locations, you can just opt to not specify a LocationSearchParameter as this should indicate that you wish to target all locations. Let me know if this helps.

Best regards,
Peter
AdWords API Team

Mark Anthony Gutierrez

unread,
Apr 2, 2018, 3:00:59 AM4/2/18
to AdWords API Forum
Hello Sir Peter,

I guess I have to option out the LocationSearchParameter because I needed to select all countries. I also tried to add all 200+ countries in the list object but it doesn't work.
But optioning out LocationSearchParamter works. Thank you so much!
Reply all
Reply to author
Forward
0 new messages