Location TargetingStay organized with collectionsSave and categorize content based on your preferences.
Page Summary
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 usingGeoTargetConstantService.SuggestGeoTargetConstants.
You can also look up location criterion IDs by location name usingGeoTargetConstantService.SuggestGeoTargetConstants.
Proximity targeting allows you to target areas within a specified radius of a specific geographical point using aProximityInfoobject.
Geo targets can be retrieved usingGoogleAdsService.SearchStream, updated by comparing existing and new targets, and excluded by setting thenegativefield totrueforLocationInfoobjects.
This guide describes location targeting, and how you can use the Google Ads API to add,
retrieve, and update location targeting for your campaigns.
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::V22::Resources::CampaignCriterion->new({# Create a location using the specified location ID.location=>Google::Ads::GoogleAds::V22::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::V22::Utils::ResourceNames::geo_target_constant($location_id)}),campaign=>$campaign_resource_name});returnGoogle::Ads::GoogleAds::V22::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.
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::V22::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::V22::Resources::CampaignCriterion->new({proximity=>Google::Ads::GoogleAds::V22::Common::ProximityInfo->new({address=>Google::Ads::GoogleAds::V22::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::V22::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.
Beyond specifying locations to target or exclude, you can refine how Google Ads
matches users to these locations using advanced location options. These settings
are managed throughCampaign.GeoTargetTypeSetting.
This setting consists of two fields:
positive_geo_target_type: Determines how users are matched for locations
youtarget.
negative_geo_target_type: Determines how users are matched for locations
youexclude.
Excludes people who are likely to be physically located in the locations
you've excluded.
People outside the excluded areas, even if interested in them, may still
see your ads, provided they match your positive targeting.
Note: ThePRESENCE_OR_INTERESTvalue is generally not supported for negative
geotargeting in most campaign types.
Manage advanced location options
You can control these settings by updating theCampaign.geo_target_type_settingobject.
Example: Setting a campaign to target byPRESENCEonly
Here's a conceptual example of how you might structure an API call to modify thepositive_geo_target_type. The exact code will vary based on the client library
language.
// Conceptual structure for a Campaign update operationoperations{update{resource_name:"customers/{customer_id}/campaigns/{campaign_id}"geo_target_type_setting{positive_geo_target_type:PRESENCE// negative_geo_target_type remains at its default PRESENCE if not specified}}update_mask{paths:"geo_target_type_setting.positive_geo_target_type"}}
To fetch the current settings, includecampaign.geo_target_type_setting.positive_geo_target_typeandcampaign.geo_target_type_setting.negative_geo_target_typein yourGoogleAdsServicesearch query.
By configuring these settings, you gain more granular control over who sees your
ads based on their relationship to the geographic locations you've specified,
aligning more closely with your business goals.
[[["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-12-11 UTC."],[],[]]