Re: Add locations with radius programmatically

755 views
Skip to first unread message

Josh Radcliff (AdWords API Team)

unread,
Aug 4, 2014, 12:17:17 PM8/4/14
to adwor...@googlegroups.com
Hi,

You can do this using a Proximity campaign criterion. See our Location Targeting Guide for more details.

Cheers,
Josh, AdWords API Team

On Monday, August 4, 2014 11:36:00 AM UTC-4, Dzmitry Zahusta wrote:
Hi here!

How is it possible to add locations with radius programmatically as I can do it using UI:

 Thank you in advance

Josh Radcliff (AdWords API Team)

unread,
Aug 4, 2014, 2:18:48 PM8/4/14
to adwor...@googlegroups.com
Hi,

Proximity criteria is the only way to do radius targeting through the API. Note that you can look up the GeoPoint that corresponds to an address (including a partial address, e.g., one based solely on postalCode) using GeoLocationService. Once you have the GeoPoint, you can then use that to construct your Proximity object.

A similar concept is LocationGroups, which allow you to target areas or demographic groups near one or more locations. See the AddCampaignTargetingCriteria.java example in each client library's targeting folder for details.

Thanks,
Josh, AdWords API Team

On Monday, August 4, 2014 1:50:12 PM UTC-4, Dzmitry Zahusta wrote:
Hi Josh!

I don't think this is right way. To add Location you need to know its criteria id (for example 21137L - California). But to add Proximity you need to know the proper address or lattitude and longitude. And there is no way to map criteria id to some address or retrieve its GeoPoint to set to Proximity. In other words - I want to get the same object to set for LocationCriterion and Proximity.

My thought is if it's possible in UI it should be possible in the code.

понедельник, 4 августа 2014 г., 19:17:17 UTC+3 пользователь Josh Radcliff (AdWords API Team) написал:

Josh Radcliff (AdWords API Team)

unread,
Aug 4, 2014, 5:21:28 PM8/4/14
to adwor...@googlegroups.com
Hi,

If you create radius targeting through the UI, you'll see that you get a Proximity object as I described. For example, I used the UI to create radius targeting around two areas in my campaign: postal code 11215, and Paris, France. This resulted in the CampaignCriterion list shown at the end of this message.

You could achieve the same thing through the API by using GeoLocationService to find the latitude & longitude for the partial address of interest. For example, for Paris, France, you'd submit a GeoLocationService request where you just populated cityName = "Paris" and countryCode = "FR".

<selector>
  <addresses>
      <cityName>Paris</cityName>
      <countryCode>FR</countryCode>
  </addresses>
</selector>

This would give you:

    <rval>
        <geoPoint>
            <latitudeInMicroDegrees>48856614</latitudeInMicroDegrees>
            <longitudeInMicroDegrees>2352221</longitudeInMicroDegrees>
        </geoPoint>
        <address>
            <cityName>Paris</cityName>
            <countryCode>FR</countryCode>
        </address>
        <encodedLocation>...</encodedLocation>
        <GeoLocation.Type>GeoLocation</GeoLocation.Type>
    </rval>
</getResponse>

You could then use that GeoPoint to construct your Proximity object.

Regards,
Josh, AdWords API Team

<entries>
    <campaignId>xxx</campaignId>
    <isNegative>false</isNegative>
    <criterion xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Proximity">
        <id>95050702855</id>
        <type>PROXIMITY</type>
        <Criterion.Type>Proximity</Criterion.Type>
        <geoPoint>
            <latitudeInMicroDegrees>40683006</latitudeInMicroDegrees>
            <longitudeInMicroDegrees>-73980064</longitudeInMicroDegrees>
        </geoPoint>
        <radiusDistanceUnits>KILOMETERS</radiusDistanceUnits>
        <radiusInUnits>20.0</radiusInUnits>
        <address>
            <cityName>Brooklyn</cityName>
            <provinceName>NY</provinceName>
            <postalCode>11215</postalCode>
            <countryCode>US</countryCode>
        </address>
    </criterion>
    <CampaignCriterion.Type>CampaignCriterion</CampaignCriterion.Type>
</entries>
<entries>
    <campaignId>xxx</campaignId>
    <isNegative>false</isNegative>
    <criterion xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Proximity">
        <id>98646096895</id>
        <type>PROXIMITY</type>
        <Criterion.Type>Proximity</Criterion.Type>
        <geoPoint>
            <latitudeInMicroDegrees>48856614</latitudeInMicroDegrees>
            <longitudeInMicroDegrees>2352221</longitudeInMicroDegrees>
        </geoPoint>
        <radiusDistanceUnits>MILES</radiusDistanceUnits>
        <radiusInUnits>20.0</radiusInUnits>
        <address>
            <cityName>Paris</cityName>
            <countryCode>FR</countryCode>
        </address>
    </criterion>
    <CampaignCriterion.Type>CampaignCriterion</CampaignCriterion.Type>
</entries>

On Monday, August 4, 2014 3:55:50 PM UTC-4, Dzmitry Zahusta wrote:
Hi,

The problem with GeoLocationService is that it returns an array of GeoLocation.

For example, even in US there are several cities with the same name - try "Paris" or "London". And if with criteria id I can uniquely choose the proper city, I have no idea how to choose the proper one (that correspond to the same city identified by criteria id) using GeoLocationService.

Do you know any solution?

понедельник, 4 августа 2014 г., 21:18:48 UTC+3 пользователь Josh Radcliff (AdWords API Team) написал:

Josh Radcliff (AdWords API Team)

unread,
Aug 7, 2014, 3:59:33 PM8/7/14
to adwor...@googlegroups.com
Hi,

There is no mapping between Location objects and GeoPoint objects. The closest you can get is to use the attributes of a Location (postal code, city, etc.) to look up a GeoPoint via GeoLocationService.

If you want to search through the list of all available locations by fields other than LocationName, I'd recommend using the CSV files we make available at the following pages:
Downloading those files and storing them locally will allow you to efficiently look up location IDs using any combination of attributes you'd like.

Cheers,
Josh, AdWords API Team

On Wednesday, August 6, 2014 10:53:05 AM UTC-4, Dzmitry Zahusta wrote:
Hi Josh!

Let's rephrase my question. I'm working with 2 AdWords objects: Location and Proximity. To find the proper Location I can use LocationCriterionService and to create the proper Proximity I can use GeoLocationService.

I need to create all programatically with no use AdWords site. And it's necessary to use the same search objects (city name, postal code, whatever) for creating Location and Proximity.

The problem that LocationCriterionService and GeoLocationService works with different parameters and return different result objects and I don't understand how to find with their use the same cities.

P.S. LocationCriterionService functionality is awful - you cannot search by anything except LocationName.

вторник, 5 августа 2014 г., 0:21:28 UTC+3 пользователь Josh Radcliff (AdWords API Team) написал:

Chirag

unread,
Nov 18, 2014, 8:06:21 AM11/18/14
to adwor...@googlegroups.com
Hello all,

I wants to use same radius Location to get Targeting Keywords.
How I can prepare object for radius?

Please help me.

Thanks

Josh Radcliff (AdWords API Team)

unread,
Nov 18, 2014, 9:19:20 AM11/18/14
to adwor...@googlegroups.com
Hi,

I don't quite understand what you're trying to do. Could you provide some more details, such as UI screenshots of the setup you are trying to emulate?

Also, could you let me know which client library you are using so I can send you links to the relevant code examples, provided they exist for your use case?

Thanks,
Josh, AdWords API Team

Josh Radcliff (AdWords API Team)

unread,
Nov 18, 2014, 10:06:48 AM11/18/14
to adwor...@googlegroups.com
Hi Chirag,

Please avoid double or triple-posting the same question. Let's continue the discussion on your other post to avoid duplication of information.

Thanks,
Josh, AdWords API Team

Chirag

unread,
Nov 19, 2014, 1:35:36 AM11/19/14
to adwor...@googlegroups.com
Hello Josh,

Ok, Let's continue on post mentioned.
Sorry for all trouble.

Thanks,
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Le Le

unread,
Nov 11, 2015, 11:38:32 PM11/11/15
to AdWords API Forum
Hi Josh,

GeoLocationService has been removed in v201509. Which service instead support to look up the GeoPoint?

Josh Radcliff (AdWords API Team)

unread,
Nov 12, 2015, 8:51:43 AM11/12/15
to AdWords API Forum
Hi,

Per the migration guide, you can use targeting by address instead when using proximity targeting. If the address is valid, the request to add the criterion will succeed. If it is invalid, you will get an API exception.

Cheers,
Josh, AdWords API Team

Petter

unread,
Nov 16, 2015, 4:12:35 AM11/16/15
to AdWords API Forum
Thanks Josh!
Reply all
Reply to author
Forward
0 new messages