Both positive and negative criteria can be used, except for theBRANDandKEYWORDcriterion type, which can only be used as negative to exclude brands
and keywords from targeting.
Forlocation targeting, a campaign with
no specified location or location groups defaults to including all regions.
Performance Max campaigns can have up to 10,000 negative keywords.
defcreate_campaign_criterion_operations(client:GoogleAdsClient,customer_id:str,)->List[MutateOperation]:"""Creates a list of MutateOperations that create new campaign criteria.Args:client: an initialized GoogleAdsClient instance.customer_id: a client customer ID.Returns:a list of MutateOperations that create new campaign criteria."""campaign_service:CampaignServiceClient=client.get_service("CampaignService")geo_target_constant_service:GeoTargetConstantServiceClient=(client.get_service("GeoTargetConstantService"))googleads_service:GoogleAdsServiceClient=client.get_service("GoogleAdsService")operations:List[MutateOperation]=[]# Set the LOCATION campaign criteria.# Target all of New York City except Brooklyn.# Location IDs are listed here:# https://developers.google.com/google-ads/api/reference/data/geotargets# and they can also be retrieved using the GeoTargetConstantService as shown# here: https://developers.google.com/google-ads/api/docs/targeting/location-targeting## We will add one positive location target for New York City (ID=1023191)# and one negative location target for Brooklyn (ID=1022762).# First, add the positive (negative = False) for New York City.mutate_operation:MutateOperation=client.get_type("MutateOperation")campaign_criterion:CampaignCriterion=(mutate_operation.campaign_criterion_operation.create)campaign_criterion.campaign=campaign_service.campaign_path(customer_id,_PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID)campaign_criterion.location.geo_target_constant=(geo_target_constant_service.geo_target_constant_path("1023191"))campaign_criterion.negative=Falseoperations.append(mutate_operation)# Next add the negative target for Brooklyn.mutate_operation:MutateOperation=client.get_type("MutateOperation")campaign_criterion:CampaignCriterion=(mutate_operation.campaign_criterion_operation.create)campaign_criterion.campaign=campaign_service.campaign_path(customer_id,_PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID)campaign_criterion.location.geo_target_constant=(geo_target_constant_service.geo_target_constant_path("1022762"))campaign_criterion.negative=Trueoperations.append(mutate_operation)# Set the LANGUAGE campaign criterion.mutate_operation:MutateOperation=client.get_type("MutateOperation")campaign_criterion:CampaignCriterion=(mutate_operation.campaign_criterion_operation.create)campaign_criterion.campaign=campaign_service.campaign_path(customer_id,_PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID)# Set the language.# For a list of all language codes, see:# https://developers.google.com/google-ads/api/reference/data/codes-formats#expandable-7campaign_criterion.language.language_constant=(googleads_service.language_constant_path("1000"))# Englishoperations.append(mutate_operation)returnoperations
# Creates a list of MutateOperations that create new campaign criteria.defcreate_campaign_criterion_operations(client,customer_id)operations=[]# Set the LOCATION campaign criteria.# Target all of New York City except Brooklyn.# Location IDs are listed here:# https://developers.google.com/google-ads/api/reference/data/geotargets# and they can also be retrieved using the GeoTargetConstantService as shown# here: https://developers.google.com/google-ads/api/docs/targeting/location-targeting## We will add one positive location target for New York City (ID=1023191)# and one negative location target for Brooklyn (ID=1022762).# First, add the positive (negative = false) for New York City.operations<<client.operation.mutatedo|m|m.campaign_criterion_operation=client.operation.create_resource.campaign_criteriondo|cc|cc.campaign=client.path.campaign(customer_id,PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID)cc.location=client.resource.location_infodo|li|li.geo_target_constant=client.path.geo_target_constant("1023191")endcc.negative=falseendend# Next add the negative target for Brooklyn.operations<<client.operation.mutatedo|m|m.campaign_criterion_operation=client.operation.create_resource.campaign_criteriondo|cc|cc.campaign=client.path.campaign(customer_id,PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID)cc.location=client.resource.location_infodo|li|li.geo_target_constant=client.path.geo_target_constant("1022762")endcc.negative=trueendend# Set the LANGUAGE campaign criterion.operations<<client.operation.mutatedo|m|m.campaign_criterion_operation=client.operation.create_resource.campaign_criteriondo|cc|cc.campaign=client.path.campaign(customer_id,PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID)# Set the language.# For a list of all language codes, see:# https://developers.google.com/google-ads/api/reference/data/codes-formats#expandable-7cc.language=client.resource.language_infodo|li|li.language_constant=client.path.language_constant("1000")# Englishendendendoperationsend
subcreate_campaign_criterion_operations{my($customer_id)=@_;my$operations=[];# Set the LOCATION campaign criteria.# Target all of New York City except Brooklyn.# Location IDs are listed here:# https://developers.google.com/google-ads/api/reference/data/geotargets# and they can also be retrieved using the GeoTargetConstantService as shown# here: https://developers.google.com/google-ads/api/docs/targeting/location-targeting.## We will add one positive location target for New York City (ID=1023191)# and one negative location target for Brooklyn (ID=1022762).# First, add the positive (negative = false) for New York City.push@$operations,Google::Ads::GoogleAds::V21::Services::GoogleAdsService::MutateOperation->new({campaignCriterionOperation=>Google::Ads::GoogleAds::V21::Services::CampaignCriterionService::CampaignCriterionOperation->new({create=>Google::Ads::GoogleAds::V21::Resources::CampaignCriterion->new({campaign=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::campaign($customer_id,PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID),location=>Google::Ads::GoogleAds::V21::Common::LocationInfo->new({geoTargetConstant=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::geo_target_constant(1023191)}),negative=>"false"})})});# Next add the negative target for Brooklyn.push@$operations,Google::Ads::GoogleAds::V21::Services::GoogleAdsService::MutateOperation->new({campaignCriterionOperation=>Google::Ads::GoogleAds::V21::Services::CampaignCriterionService::CampaignCriterionOperation->new({create=>Google::Ads::GoogleAds::V21::Resources::CampaignCriterion->new({campaign=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::campaign($customer_id,PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID),location=>Google::Ads::GoogleAds::V21::Common::LocationInfo->new({geoTargetConstant=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::geo_target_constant(1022762)}),negative=>"true"})})});# Set the LANGUAGE campaign criterion.push@$operations,Google::Ads::GoogleAds::V21::Services::GoogleAdsService::MutateOperation->new({campaignCriterionOperation=>Google::Ads::GoogleAds::V21::Services::CampaignCriterionService::CampaignCriterionOperation->new({create=>Google::Ads::GoogleAds::V21::Resources::CampaignCriterion->new({campaign=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::campaign($customer_id,PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID),# Set the language.# For a list of all language codes, see:# https://developers.google.com/google-ads/api/reference/data/codes-formats#expandable-7.language=>Google::Ads::GoogleAds::V21::Common::LanguageInfo->new({languageConstant=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::language_constant(1000)# English})})})});return$operations;}
[[["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\u003ePerformance Max campaigns can be targeted using criteria such as ad schedules, brands (negative only), languages, locations, and webpages.\u003c/p\u003e\n"],["\u003cp\u003eLocation targeting defaults to all regions if no specific locations or location groups are defined for a campaign.\u003c/p\u003e\n"],["\u003cp\u003eUtilize negative webpage criteria to exclude specific URLs from Final URL expansion in your Performance Max campaigns.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eBRAND\u003c/code\u003e criterion type can only be used negatively to exclude specific brands from your campaign targeting.\u003c/p\u003e\n"],["\u003cp\u003eAn interactive guide is available to help you create campaign criteria for Performance Max campaigns, providing a hands-on approach to understanding this feature.\u003c/p\u003e\n"]]],[],null,[]]