Stay organized with collectionsSave and categorize content based on your preferences.
This guide describes location targeting, and how you can use the Google Ads API to add,
retrieve, and update location targeting for your campaigns.
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.
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 usingGeoTargetConstantService.SuggestGeoTargetConstants.
Theresource_nameof eachGeoTargetConstantis
of the formgeoTargetConstants/{Criterion ID}. For example, theresource_namevalue of New York state isgeoTargetConstants/21167.
You can add geo targets to your campaigns using theCampaignCriterionService. The following
code snippet shows how to target your campaign with a criterion ID.
defcreate_location_op(client:GoogleAdsClient,customer_id:str,campaign_id:str,location_id:str,)->CampaignCriterionOperation:campaign_service:CampaignServiceClient=client.get_service("CampaignService")geo_target_constant_service:GeoTargetConstantServiceClient=(client.get_service("GeoTargetConstantService"))# Create the campaign criterion.campaign_criterion_operation:CampaignCriterionOperation=client.get_type("CampaignCriterionOperation")campaign_criterion:CampaignCriterion=campaign_criterion_operation.createcampaign_criterion.campaign=campaign_service.campaign_path(customer_id,campaign_id)# Besides using location_id, you can also search by location names from# GeoTargetConstantService.suggest_geo_target_constants() and directly# apply GeoTargetConstant.resource_name here. An example can be found# in get_geo_target_constant_by_names.py.campaign_criterion.location.geo_target_constant=(geo_target_constant_service.geo_target_constant_path(location_id))returncampaign_criterion_operation
defcreate_location(client,customer_id,campaign_id,location_id)client.operation.create_resource.campaign_criteriondo|criterion|criterion.campaign=client.path.campaign(customer_id,campaign_id)criterion.location=client.resource.location_infodo|li|# Besides using location_id, you can also search by location names from# GeoTargetConstantService.suggest_geo_target_constants() and directly# apply GeoTargetConstant.resource_name here. An example can be found# in get_geo_target_constant_by_names.rb.li.geo_target_constant=client.path.geo_target_constant(location_id)endendend
subcreate_location_campaign_criterion_operation{my($location_id,$campaign_resource_name)=@_;# Construct a campaign criterion for the specified campaign using the# specified location ID.my$campaign_criterion=Google::Ads::GoogleAds::V21::Resources::CampaignCriterion->new({# Create a location using the specified location ID.location=>Google::Ads::GoogleAds::V21::Common::LocationInfo->new({# Besides using location ID, you can also search by location names# using GeoTargetConstantService::suggest() and directly apply# GeoTargetConstant->{resourceName} here. An example can be found# in get_geo_target_constants_by_names.pl.geoTargetConstant=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::geo_target_constant($location_id)}),campaign=>$campaign_resource_name});returnGoogle::Ads::GoogleAds::V21::Services::CampaignCriterionService::CampaignCriterionOperation->new({create=>$campaign_criterion});}
Google may occasionally phase out some location criteria for various reasons:
the location may be restructured into smaller or larger areas, geo-political
changes, etc. Refer to thestatusfield of
aGeoTargetConstantobject to determine if a location isENABLEDorREMOVAL_PLANNED.
Read more abouthow location targets are phased out.
Look up by location name
You can also look up the criterion ID by location name usingGeoTargetConstantService.SuggestGeoTargetConstants.
The following code example shows how to look up a location criterion ID by
location name.
defmain(client:GoogleAdsClient)->None:gtc_service:GeoTargetConstantServiceClient=client.get_service("GeoTargetConstantService")gtc_request:SuggestGeoTargetConstantsRequest=client.get_type("SuggestGeoTargetConstantsRequest")gtc_request.locale=LOCALEgtc_request.country_code=COUNTRY_CODE# The location names to get suggested geo target constants.# Type hint for gtc_request.location_names.names is not straightforward# as it's part of a complex protobuf object.gtc_request.location_names.names.extend(["Paris","Quebec","Spain","Deutschland"])results:SuggestGeoTargetConstantsResponse=(gtc_service.suggest_geo_target_constants(gtc_request))suggestion:GeoTargetConstantSuggestionforsuggestioninresults.geo_target_constant_suggestions:geo_target_constant:GeoTargetConstant=suggestion.geo_target_constantprint(f"{geo_target_constant.resource_name}"f"({geo_target_constant.name}, "f"{geo_target_constant.country_code}, "f"{geo_target_constant.target_type}, "f"{geo_target_constant.status.name}) "f"is found in locale ({suggestion.locale}) "f"with reach ({suggestion.reach}) "f"from search term ({suggestion.search_term}).")
defget_geo_target_constants_by_names# GoogleAdsClient will read a config file from# ENV['HOME']/google_ads_config.rb when called without parametersclient=Google::Ads::GoogleAds::GoogleAdsClient.newgtc_service=client.service.geo_target_constantlocation_names=client.resource.location_namesdo|ln|['Paris','Quebec','Spain','Deutschland'].eachdo|name|ln.names<<nameendend# Locale is using ISO 639-1 format. If an invalid locale is given,# 'en' is used by default.locale='en'# A list of country codes can be referenced here:# https://developers.google.com/google-ads/api/reference/data/geotargetscountry_code='FR'response=gtc_service.suggest_geo_target_constants(locale:locale,country_code:country_code,location_names:location_names)response.geo_target_constant_suggestions.eachdo|suggestion|putssprintf("%s (%s,%s,%s,%s) is found in locale (%s) with reach (%d)"\" from search term (%s).",suggestion.geo_target_constant.resource_name,suggestion.geo_target_constant.name,suggestion.geo_target_constant.country_code,suggestion.geo_target_constant.target_type,suggestion.geo_target_constant.status,suggestion.locale,suggestion.reach,suggestion.search_term)endend
subget_geo_target_constants_by_names{my($api_client,$location_names,$locale,$country_code)=@_;my$suggest_response=$api_client->GeoTargetConstantService()->suggest({locale=>$locale,countryCode=>$country_code,locationNames=>Google::Ads::GoogleAds::V21::Services::GeoTargetConstantService::LocationNames->new({names=>$location_names})});# Iterate over all geo target constant suggestion objects and print the requested# field values for each one.foreachmy$geo_target_constant_suggestion(@{$suggest_response->{geoTargetConstantSuggestions}}){printf"Found '%s' ('%s','%s','%s',%s) in locale '%s' with reach %d"." for the search term '%s'.\n",$geo_target_constant_suggestion->{geoTargetConstant}{resourceName},$geo_target_constant_suggestion->{geoTargetConstant}{name},$geo_target_constant_suggestion->{geoTargetConstant}{countryCode},$geo_target_constant_suggestion->{geoTargetConstant}{targetType},$geo_target_constant_suggestion->{geoTargetConstant}{status},$geo_target_constant_suggestion->{locale},$geo_target_constant_suggestion->{reach},$geo_target_constant_suggestion->{searchTerm};}return1;}
There are times when you might want to target even more precisely than a city or
country. For example, you may want to advertise your supermarkets within 10
kilometers of your shop location. In such cases, you can useproximity targeting.
The code to create a proximity target is similar to adding a location target,
except that you have to create aProximityInfoobject instead of aLocationInfoobject.
defcreate_proximity_op(client:GoogleAdsClient,customer_id:str,campaign_id:str)->CampaignCriterionOperation:campaign_service:CampaignServiceClient=client.get_service("CampaignService")# Create the campaign criterion.campaign_criterion_operation:CampaignCriterionOperation=client.get_type("CampaignCriterionOperation")campaign_criterion:CampaignCriterion=campaign_criterion_operation.createcampaign_criterion.campaign=campaign_service.campaign_path(customer_id,campaign_id)campaign_criterion.proximity.address.street_address="38 avenue de l'Opera"campaign_criterion.proximity.address.city_name="Paris"campaign_criterion.proximity.address.postal_code="75002"campaign_criterion.proximity.address.country_code="FR"campaign_criterion.proximity.radius=10# Default is kilometers.campaign_criterion.proximity.radius_units=(client.enums.ProximityRadiusUnitsEnum.MILES)returncampaign_criterion_operation
defcreate_proximity(client,customer_id,campaign_id)client.operation.create_resource.campaign_criteriondo|criterion|criterion.campaign=client.path.campaign(customer_id,campaign_id)criterion.proximity=client.resource.proximity_infodo|proximity|proximity.address=client.resource.address_infodo|address|address.street_address="38 avenue de l'Opéra"address.city_name="Paris"address.postal_code="75002"address.country_code="FR"endproximity.radius=10proximity.radius_units=:MILESendendend
subcreate_proximity_campaign_criterion_operation{my($campaign_resource_name)=@_;# Construct a campaign criterion as a proximity.my$campaign_criterion=Google::Ads::GoogleAds::V21::Resources::CampaignCriterion->new({proximity=>Google::Ads::GoogleAds::V21::Common::ProximityInfo->new({address=>Google::Ads::GoogleAds::V21::Common::AddressInfo->new({streetAddress=>"38 avenue de l'Opéra",cityName=>"cityName",postalCode=>"75002",countryCode=>"FR"}),radius=>10.0,# Default is kilometers.radiusUnits=>MILES}),campaign=>$campaign_resource_name});returnGoogle::Ads::GoogleAds::V21::Services::CampaignCriterionService::CampaignCriterionOperation->new({create=>$campaign_criterion});}
To update location targets for a campaign, you need to retrieve the list of
existing geo targets and compare it with the list of new targets. You can then
use theremoveoperation to remove the targets you don't need, and thecreateoperation to add the new geo targets you need (but are missing in the
existing campaign).
Exclude geo targets
You can also excludeLocationInfo, but notProximityInfo. This feature is most useful if
you want to target a region, but exclude a sub-region (for example, to target
the entire United States, except for New York City). To exclude a region, set
thenegativefield inCampaignCriterionto betrue.
Target multiple geographic regions
Using aLocationGroupInfo, you can enable a
campaign to target multiple geographic regions. A region is centered on the
locations defined by the location extensions of the campaign.
The radius defined on theLocationGroupInfoascribes a circular region around
each location, and consists of aradiusobject, length, andradius_units, which can be either meters or
miles (LocationGroupRadiusUnitsEnum).
The locations in aLocationGroupInfocan be filtered by a list of geotargetingcriterion IDsprescribed in thegeo_target_constantfield. If defined, no locations that existoutsideof
the given criteria IDs will be targeted.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-03 UTC."],[[["\u003cp\u003eGoogle Ads API allows advertisers to target users based on their location, including regions, proximity to a point, or by location name, ensuring ads are shown to relevant audiences.\u003c/p\u003e\n"],["\u003cp\u003eLocation targeting is achieved by using Criterion IDs obtained through \u003ccode\u003eGeoTargetConstantService\u003c/code\u003e and applied to campaigns using \u003ccode\u003eCampaignCriterionService\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAdvertisers can refine their reach by specifying radii around addresses for proximity targeting or by searching for locations using names, locales, and country codes.\u003c/p\u003e\n"],["\u003cp\u003eMonitoring the \u003ccode\u003estatus\u003c/code\u003e field of \u003ccode\u003eGeoTargetConstant\u003c/code\u003e objects is crucial to stay informed about location availability changes.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eGoogleAdsService.SearchStream\u003c/code\u003e enables retrieving and updating existing geo-targets for campaigns, ensuring location targeting strategies remain aligned with campaign goals.\u003c/p\u003e\n"]]],[],null,[]]