![]() |
Google Ads API Team |
Hi,
Thanks for getting back to us.
As per the ValueRuleGeoLocationCondition.geo_target_constants[] guide, it is a string representation of Geo locations that advertisers want to include. That said, can you try setting this value to a string of geo_target_constants?
Let us know how it goes.

Hi,
Thank you for your response.
As we previously provide under the rules conditions (https://developers.google.com/google-ads/api/docs/conversions/conversion-value-rules#rule_conditions), it was mentioned that you need to consult the location targeting guide (https://developers.google.com/google-ads/api/docs/targeting/location-targeting#retrieve_geo_targets) for how to retrieve location resource names. Then, to retrieve geo targets directly from the Google Ads API, query the geo_target_constant (https://developers.google.com/google-ads/api/fields/v14/geo_target_constant) field. You may also check this documentation (https://developers.google.com/google-ads/api/data/geotargets?hl=en) for geotargets.
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups "Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/NxFnc000000000000000000000000000000000000000000000RZEBCK00lqmMKQWURVGMd0M-nwjApw%40sfdc.net.
Hi there,
You may use campaignCriterionService to set the location targeting as the CampaignCriterionService, AdGroupCriterionService, and CustomerNegativeCriterionService support targeting or excluding various types of criteria.
You may see following criteria:
Named location targeting is implemented as LocationInfo and are created using a fixed set of criteria IDs. The available IDs are listed in the documentation and can be individually searched for using the GeoTargetConstantService. These criteria can be configured as either positive or negative, with negative targets overriding positive ones. By default a new campaign will contain no location criteria, which means that all locations are targeted. You may check more about Named location targeting.
Radius targets are implemented as ProximityInfo criteria. They can be created using either an address or latitude/longitude, and by specifying a radius. They can only be configured as positive, and by default a new campaign will not contain proximity criteria. You may check more about Radius targeting.
A LocationGroup lets campaigns target multiple geographic regions. These regions are defined by a set of locations and a distance radius around each location in either meters or miles. The set of locations is derived from the location extensions for the campaign. You can optionally use a Feed to define the set of locations. The targeting of these locations can be filtered using a list of geotargeting criteria IDs. You may check more about targeting multiple geographic regions.
Once you already have the targeting, then you may refer to the location targeting guide for how to retrieve location resource names. For more information, you may see below links:
Let us know if you have any questions.
Hi,
Thank you for coming back to us and providing your insights. I hope you are doing well today.
In relation to your concern, please code sample below for reference.
Request ------- MethodName: google.ads.googleads.v14.services.ConversionValueRuleService/MutateConversionValueRules Endpoint: googleads.googleapis.com:443 Headers: {developer-token=REDACTED, x-goog-api-client=gl-java/15.0.7 gccl/25.0.1-SNAPSHOT gapic/25.0.1-SNAPSHOT gax/2.29.0 grpc/1.55.1} Body: customer_id: "4985776047" operations { create { action { operation: ADD value: 45.0 } geo_location_condition { geo_target_constants: "geoTargetConstants/1014044" geo_match_type: ANY } } } validate_only: true response_content_type: MUTABLE_RESOURCE partial_failure: true
Response -------- Headers: Metadata(content-disposition=attachment,content-type=application/grpc,request-id=1AB7zOJHHOrDg_RTPIaOuw,date=Tue, 15 Aug 2023 17:50:56 GMT,alt-svc=h3=":443"; ma=2592000,h3-29=":443"; ma=2592000) Body: Failure message: null Status: Status{code=OK, description=null, cause=null}.
I have raised a feature request for this to be available in the Google Ads API documentation. This request is subject for review and for now, I would suggest keeping an eye on our blog post (https://ads-developers.googleblog.com/) or release notes (https://developers.google.com/google-ads/api/docs/release-notes) for the updates.
I hope this will help you. Have a great day.
public class ConversionValueRule {
public static void main(String[] args) {
AddConversionValueRuleParams params = new AddConversionValueRuleParams();
if (!params.parseArguments(args)) {
// Either pass the required parameters for this example on the command line, or insert them
// into the code here. See the parameter class definition above for descriptions.
params.customerId = Long.parseLong("4985776047");
}
GoogleAdsClient googleAdsClient = null;
try {
googleAdsClient = GoogleAdsClient.newBuilder().fromPropertiesFile().build();
} catch (FileNotFoundException fnfe) {
System.err.printf(
"Failed to load GoogleAdsClient configuration from file. Exception: %s%n", fnfe);
System.exit(1);
} catch (IOException ioe) {
System.err.printf("Failed to create GoogleAdsClient. Exception: %s%n", ioe);
System.exit(1);
}
try {
new ConversionValueRule().runExample1(googleAdsClient, params.customerId);
} catch (GoogleAdsException gae) {
// GoogleAdsException is the base class for most exceptions thrown by an API request.
// Instances of this exception have a message and a GoogleAdsFailure that contains a
// collection of GoogleAdsErrors that indicate the underlying causes of the
// GoogleAdsException.
System.err.printf(
"Request ID %s failed due to GoogleAdsException. Underlying errors:%n",
gae.getRequestId());
int i = 0;
for (GoogleAdsError googleAdsError : gae.getGoogleAdsFailure().getErrorsList()) {
System.err.printf(" Error %d: %s%n", i++, googleAdsError);
}
System.exit(1);
}
}
private void runExample1(GoogleAdsClient googleAdsClient, long customerId) {
List<String> geoTargetCountryCodes = ImmutableList.of("US");
// Create a geo location condition.
com.google.ads.googleads.v14.resources.ConversionValueRule.ValueRuleGeoLocationCondition geoLocationCondition = com.google.ads.googleads.v14.resources.ConversionValueRule.ValueRuleGeoLocationCondition.newBuilder()
.addGeoTargetConstants("geoTargetConstants/1014044")
.setGeoMatchType(ValueRuleGeoLocationMatchTypeEnum.ValueRuleGeoLocationMatchType.ANY)
.build();
com.google.ads.googleads.v14.resources.ConversionValueRule conversionValueRule =
com.google.ads.googleads.v14.resources.ConversionValueRule.newBuilder()
.setAction(com.google.ads.googleads.v14.resources.ConversionValueRule.ValueRuleAction.newBuilder().setOperation(ValueRuleOperationEnum.ValueRuleOperation.ADD).setValue(45).build())
.setGeoLocationCondition(geoLocationCondition)
.build();
// Creates the operation.
ConversionValueRuleOperation operation = ConversionValueRuleOperation.newBuilder()
.setCreate(conversionValueRule).build();
try (ConversionValueRuleServiceClient conversionValueRuleServiceClient =
googleAdsClient.getLatestVersion().createConversionValueRuleServiceClient()) {
MutateConversionValueRulesRequest request =
MutateConversionValueRulesRequest.newBuilder()
.setCustomerId("XXXX")
.addAllOperations(Collections.singletonList(operation))
.setPartialFailure(true)
.setValidateOnly(false)
.setResponseContentType(ResponseContentTypeEnum.ResponseContentType.MUTABLE_RESOURCE)
.build();
MutateConversionValueRulesResponse response =
conversionValueRuleServiceClient.mutateConversionValueRules(request);
}
}
private static class AddConversionActionParams extends CodeSampleParams {
@Parameter(names = ArgumentNames.CUSTOMER_ID, required = true)
private Long customerId;
}
}
I hope this helps.