Location Targeting

  • Location targeting allows you to serve ads to users in specific geographical areas, preventing wasted ad spend in irrelevant regions and enabling direct targeting of local customers.

  • Geo targeting campaigns for a region can be done using a Criterion ID, which uniquely identifies each targetable location and can be looked up using GeoTargetConstantService.SuggestGeoTargetConstants.

  • You can also look up location criterion IDs by location name using GeoTargetConstantService.SuggestGeoTargetConstants.

  • Proximity targeting allows you to target areas within a specified radius of a specific geographical point using a ProximityInfo object.

  • Geo targets can be retrieved using GoogleAdsService.SearchStream, updated by comparing existing and new targets, and excluded by setting the negative field to true for LocationInfo objects.

This guide describes location targeting, and how you can use the Google Ads API to add, retrieve, and update location targeting for your campaigns.

For information about targeting limits, see the Targeting Limits section of About Google Ads account limits.

Why is geo-targeting important?

Location targeting lets you serve ads to users in a particular geographical region. For example, assume you're advertising for a chain of supermarkets. Without location targeting, your ads would show in all regions worldwide, and your ads might receive clicks from users in regions where you have no supermarket locations. This generates cost while providing no possibility of a return on the investment. With location targeting, your campaigns show ads only in regions where you have open supermarkets. This approach also lets you directly target customers searching locally for supermarkets.

The Google Ads API lets you target your ads by country, region, or proximity around a specific geographical point.

Learn more about Targeting ads to geographic locations.

Geo-target campaigns for a region

You can target campaigns to any geographical region for which Google Ads supports location targeting, such as a country, a state, a city, or a postal region. Each targetable location is uniquely identified by a Criterion ID. You can look up a criterion ID using GeoTargetConstantService.SuggestGeoTargetConstants. The resource_name of each GeoTargetConstant is of the form geoTargetConstants/{Criterion ID}. For example, the resource_name value of New York state is geoTargetConstants/21167.

You can add geo targets to your campaigns using the CampaignCriterionService. The following code snippet shows how to target your campaign with a criterion ID.

Java

private static CampaignCriterion buildLocationIdCriterion(
    long locationId, String campaignResourceName) {
  Builder criterionBuilder = CampaignCriterion.newBuilder().setCampaign(campaignResourceName);

  criterionBuilder
      .getLocationBuilder()
      .setGeoTargetConstant(ResourceNames.geoTargetConstant(locationId));

  return criterionBuilder.build();
}
      

C#

private CampaignCriterion buildLocationCriterion(long locationId,
    string campaignResourceName)
{
    GeoTargetConstantName location = new GeoTargetConstantName(locationId.ToString());
    return new CampaignCriterion()
    {
        Campaign = campaignResourceName,
        Location = new LocationInfo()
        {
            GeoTargetConstant = location.ToString()
        }
    };
}
      

PHP

private static function createLocationCampaignCriterionOperation(
    int $locationId,
    string $campaignResourceName
) {
    // Constructs a campaign criterion for the specified campaign ID using the specified
    // location ID.
    $campaignCriterion = new CampaignCriterion([
        // Creates a location using the specified location ID.
        'location' => new LocationInfo([
            // Besides using location ID, you can also search by location names using
            // GeoTargetConstantServiceClient::suggestGeoTargetConstants() and directly
            // apply GeoTargetConstant::$resourceName here. An example can be found
            // in GetGeoTargetConstantByNames.php.
            'geo_target_constant' => ResourceNames::forGeoTargetConstant($locationId)
        ]),
        'campaign' => $campaignResourceName
    ]);

    return new CampaignCriterionOperation(['create' => $campaignCriterion]);
}