Stay organized with collectionsSave and categorize content based on your preferences.
This guide provides a checklist of concepts and tasks for each of the three
Performance Max business goals to help you build your campaign. To get started,
select a business goal:
Performance Max for online sales or lead generation (standard)
Performance Maxallows
advertisers to access all Google Ads channels and inventory from a single,
unified campaign. The steps to create a standard Performance Max campaign are as follows. Click
the links in each section for more information.
Performance Max concepts
One of the most common goals among advertisers is to encourage customers to
pursue a specific action to achieve a goals such as generating sales or leads.
In the Google Ads API, Performance Max campaigns for online sales or lead generation
are often referred to asstandardPerformance Max campaigns.
When creating a Performance Max campaign, you can use abulk mutate
requestto create the resources required to form
a valid, serving campaign in a single request. Not all resources must be created
in a single bulk mutate request. The following resources are required to create
a valid, serving Performance Max campaign. Learn more in theStructure requests guide.
CampaignBudget
Campaign
CampaignAssets(for campaigns with brand guidelines enabled only)
defcreate_campaign_budget_operation(client:GoogleAdsClient,customer_id:str,)->MutateOperation:"""Creates a MutateOperation that creates a new CampaignBudget.A temporary ID will be assigned to this campaign budget so that it can bereferenced by other objects being created in the same Mutate request.Args:client: an initialized GoogleAdsClient instance.customer_id: a client customer ID.Returns:a MutateOperation that creates a CampaignBudget."""mutate_operation:MutateOperation=client.get_type("MutateOperation")campaign_budget_operation:CampaignBudgetOperation=(mutate_operation.campaign_budget_operation)campaign_budget:CampaignBudget=campaign_budget_operation.createcampaign_budget.name=f"Performance Max campaign budget #{uuid4()}"# The budget period already defaults to DAILY.campaign_budget.amount_micros=50000000campaign_budget.delivery_method=(client.enums.BudgetDeliveryMethodEnum.STANDARD)# A Performance Max campaign cannot use a shared campaign budget.campaign_budget.explicitly_shared=False# Set a temporary ID in the budget's resource name so it can be referenced# by the campaign in later steps.campaign_budget.resource_name=client.get_service("CampaignBudgetService").campaign_budget_path(customer_id,_BUDGET_TEMPORARY_ID)returnmutate_operation
# Creates a MutateOperation that creates a new CampaignBudget.## A temporary ID will be assigned to this campaign budget so that it can be# referenced by other objects being created in the same Mutate request.defcreate_campaign_budget_operation(client,customer_id)client.operation.mutatedo|m|m.campaign_budget_operation=client.operation.create_resource.campaign_budgetdo|cb|cb.name="Performance Max campaign budget#{SecureRandom.uuid}"# The budget period already defaults to DAILY.cb.amount_micros=50_000_000cb.delivery_method=:STANDARD# A Performance Max campaign cannot use a shared campaign budget.cb.explicitly_shared=false# Set a temporary ID in the budget's resource name so it can be referenced# by the campaign in later steps.cb.resource_name=client.path.campaign_budget(customer_id,BUDGET_TEMPORARY_ID)endendend
subcreate_campaign_budget_operation{my($customer_id)=@_;# Create a mutate operation that creates a campaign budget operation.returnGoogle::Ads::GoogleAds::V21::Services::GoogleAdsService::MutateOperation->new({campaignBudgetOperation=>Google::Ads::GoogleAds::V21::Services::CampaignBudgetService::CampaignBudgetOperation->new({create=>Google::Ads::GoogleAds::V21::Resources::CampaignBudget->new({# Set a temporary ID in the budget's resource name so it can be# referenced by the campaign in later steps.resourceName=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::campaign_budget($customer_id,BUDGET_TEMPORARY_ID),name=>"Performance Max campaign budget #".uniqid(),# The budget period already defaults to DAILY.amountMicros=>50000000,deliveryMethod=>STANDARD,# A Performance Max campaign cannot use a shared campaign budget.explicitlyShared=>"false",})})});}
defcreate_performance_max_campaign_operation(client:GoogleAdsClient,customer_id:str,brand_guidelines_enabled:bool,)->MutateOperation:"""Creates a MutateOperation that creates a new Performance Max campaign.A temporary ID will be assigned to this campaign so that it canbe referenced by other objects being created in the same Mutate request.Args:client: an initialized GoogleAdsClient instance.customer_id: a client customer ID.brand_guidelines_enabled: a boolean value indicating if the campaign isenabled for brand guidelines.Returns:a MutateOperation that creates a campaign."""mutate_operation:MutateOperation=client.get_type("MutateOperation")campaign:Campaign=mutate_operation.campaign_operation.createcampaign.name=f"Performance Max campaign #{uuid4()}"# Set the campaign status as PAUSED. The campaign is the only entity in# the mutate request that should have its status set.campaign.status=client.enums.CampaignStatusEnum.PAUSED# All Performance Max campaigns have an advertising_channel_type of# PERFORMANCE_MAX. The advertising_channel_sub_type should not be set.campaign.advertising_channel_type=(client.enums.AdvertisingChannelTypeEnum.PERFORMANCE_MAX)# Bidding strategy must be set directly on the campaign.# Setting a portfolio bidding strategy by resource name is not supported.# Max Conversion and Maximize Conversion Value are the only strategies# supported for Performance Max campaigns.# An optional ROAS (Return on Advertising Spend) can be set for# maximize_conversion_value. The ROAS value must be specified as a ratio in# the API. It is calculated by dividing "total value" by "total spend".# For more information on Maximize Conversion Value, see the support# article: http://support.google.com/google-ads/answer/7684216.# A target_roas of 3.5 corresponds to a 350% return on ad spend.campaign.bidding_strategy_type=(client.enums.BiddingStrategyTypeEnum.MAXIMIZE_CONVERSION_VALUE)campaign.maximize_conversion_value.target_roas=3.5# Set the Final URL expansion opt out. This flag is specific to# Performance Max campaigns. If opted out (True), only the final URLs in# the asset group or URLs specified in the advertiser's Google Merchant# Center or business data feeds are targeted.# If opted in (False), the entire domain will be targeted. For best# results, set this value to false to opt in and allow URL expansions. You# can optionally add exclusions to limit traffic to parts of your website.campaign.url_expansion_opt_out=False# Set if the campaign is enabled for brand guidelines. For more information# on brand guidelines, see https://support.google.com/google-ads/answer/14934472.campaign.brand_guidelines_enabled=brand_guidelines_enabled# Assign the resource name with a temporary ID.campaign_service:CampaignServiceClient=client.get_service("CampaignService")campaign.resource_name=campaign_service.campaign_path(customer_id,_PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID)# Set the budget using the given budget resource name.campaign.campaign_budget=campaign_service.campaign_budget_path(customer_id,_BUDGET_TEMPORARY_ID)# Declare whether or not this campaign serves political ads targeting the# EU. Valid values are:# CONTAINS_EU_POLITICAL_ADVERTISING# DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISINGcampaign.contains_eu_political_advertising=(client.enums.EuPoliticalAdvertisingStatusEnum.DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING)# Optional fieldscampaign.start_date=(datetime.now()+timedelta(1)).strftime("%Y%m%d")campaign.end_date=(datetime.now()+timedelta(365)).strftime("%Y%m%d")returnmutate_operation
# Creates a MutateOperation that creates a new Performance Max campaign.## A temporary ID will be assigned to this campaign so that it can# be referenced by other objects being created in the same Mutate request.defcreate_performance_max_campaign_operation(client,customer_id,brand_guidelines_enabled)client.operation.mutatedo|m|m.campaign_operation=client.operation.create_resource.campaigndo|c|c.name="Performance Max campaign#{SecureRandom.uuid}"# Set the campaign status as PAUSED. The campaign is the only entity in# the mutate request that should have its status set.c.status=:PAUSED# All Performance Max campaigns have an advertising_channel_type of# PERFORMANCE_MAX. The advertising_channel_sub_type should not be set.c.advertising_channel_type=:PERFORMANCE_MAX# Bidding strategy must be set directly on the campaign.# Setting a portfolio bidding strategy by resource name is not supported.# Max Conversion and Maximize Conversion Value are the only strategies# supported for Performance Max campaigns.# An optional ROAS (Return on Advertising Spend) can be set for# maximize_conversion_value. The ROAS value must be specified as a ratio in# the API. It is calculated by dividing "total value" by "total spend".# For more information on Maximize Conversion Value, see the support# article: http://support.google.com/google-ads/answer/7684216.# A target_roas of 3.5 corresponds to a 350% return on ad spend.c.bidding_strategy_type=:MAXIMIZE_CONVERSION_VALUEc.maximize_conversion_value=client.resource.maximize_conversion_valuedo|mcv|mcv.target_roas=3.5end# Set the Final URL expansion opt out. This flag is specific to# Performance Max campaigns. If opted out (true), only the final URLs in# the asset group or URLs specified in the advertiser's Google Merchant# Center or business data feeds are targeted.# If opted in (false), the entire domain will be targeted. For best# results, set this value to false to opt in and allow URL expansions. You# can optionally add exclusions to limit traffic to parts of your website.c.url_expansion_opt_out=false# Set if the campaign is enabled for brand guidelines. For more# information on brand guidelines, see# https://support.google.com/google-ads/answer/14934472.c.brand_guidelines_enabled=brand_guidelines_enabled# Assign the resource name with a temporary ID.c.resource_name=client.path.campaign(customer_id,PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID)# Set the budget using the given budget resource name.c.campaign_budget=client.path.campaign_budget(customer_id,BUDGET_TEMPORARY_ID)# Declare whether or not this campaign serves political ads targeting the EU.# Valid values are CONTAINS_EU_POLITICAL_ADVERTISING and# DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING.c.contains_eu_political_advertising=:DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING# Optional fieldsc.start_date=DateTime.parse((Date.today+1).to_s).strftime('%Y%m%d')c.end_date=DateTime.parse(Date.today.next_year.to_s).strftime('%Y%m%d')endendend
subcreate_performance_max_campaign_operation{my($customer_id,$brand_guidelines_enabled)=@_;# Create a mutate operation that creates a campaign operation.returnGoogle::Ads::GoogleAds::V21::Services::GoogleAdsService::MutateOperation->new({campaignOperation=>Google::Ads::GoogleAds::V21::Services::CampaignService::CampaignOperation->new({create=>Google::Ads::GoogleAds::V21::Resources::Campaign->new({# Assign the resource name with a temporary ID.resourceName=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::campaign($customer_id,PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID),name=>"Performance Max campaign #".uniqid(),# Set the budget using the given budget resource name.campaignBudget=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::campaign_budget($customer_id,BUDGET_TEMPORARY_ID),# Set the campaign status as PAUSED. The campaign is the only entity in# the mutate request that should have its status set.status=>Google::Ads::GoogleAds::V21::Enums::CampaignStatusEnum::PAUSED,# All Performance Max campaigns have an advertisingChannelType of# PERFORMANCE_MAX. The advertisingChannelSubType should not be set.advertisingChannelType=>PERFORMANCE_MAX,# Bidding strategy must be set directly on the campaign.# Setting a portfolio bidding strategy by resource name is not supported.# Max Conversion and Maximize Conversion Value are the only strategies# supported for Performance Max campaigns.# An optional ROAS (Return on Advertising Spend) can be set for# maximizeConversionValue. The ROAS value must be specified as a ratio in# the API. It is calculated by dividing "total value" by "total spend".# For more information on Maximize Conversion Value, see the support# article: http://support.google.com/google-ads/answer/7684216.# A targetRoas of 3.5 corresponds to a 350% return on ad spend.maximizeConversionValue=>Google::Ads::GoogleAds::V21::Common::MaximizeConversionValue->new({targetRoas=>3.5}),# Set the final URL expansion opt out. This flag is specific to# Performance Max campaigns. If opted out (true), only the final URLs in# the asset group or URLs specified in the advertiser's Google Merchant# Center or business data feeds are targeted.# If opted in (false), the entire domain will be targeted. For best# results, set this value to false to opt in and allow URL expansions. You# can optionally add exclusions to limit traffic to parts of your website.urlExpansionOptOut=>"false",# Set if the campaign is enabled for brand guidelines. For more information# on brand guidelines, see https://support.google.com/google-ads/answer/14934472.brandGuidelinesEnabled=>$brand_guidelines_enabled,# Optional fields.startDate=>strftime("%Y%m%d",localtime(time+60*60*24)),endDate=>strftime("%Y%m%d",localtime(time+60*60*24*365)),# Declare whether or not this campaign serves political ads targeting the EU.# Valid values are CONTAINS_EU_POLITICAL_ADVERTISING and# DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING.containsEuPoliticalAdvertising=>DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING})})});}
In some cases, such as when brand guidelines are enabled for a campaign, assets
must be linked to a campaign directly. This can be done with aCampaignAssetby providing the following:
Refer to theAssetsguide for assets linked to the campaign. See theCreate a campaignguide for more information on Performance Max campaigns with brand guidelines
enabled.
defget_customer_conversion_goals(client:GoogleAdsClient,customer_id:str)->List[Dict[str,Union[ConversionActionCategoryEnum.ConversionActionCategory,ConversionOriginEnum.ConversionOrigin,],]]:"""Retrieves the list of customer conversion goals.Args:client: an initialized GoogleAdsClient instance.customer_id: a client customer ID.Returns:a list of dicts containing the category and origin of customerconversion goals."""ga_service:GoogleAdsServiceClient=client.get_service("GoogleAdsService")customer_conversion_goals:List[Dict[str,Union[ConversionActionCategoryEnum.ConversionActionCategory,ConversionOriginEnum.ConversionOrigin,],]]=[]query:str="""SELECTcustomer_conversion_goal.category,customer_conversion_goal.originFROM customer_conversion_goal"""# The number of conversion goals is typically less than 50 so we use# GoogleAdsService.search instead of search_stream.search_request:SearchGoogleAdsRequest=client.get_type("SearchGoogleAdsRequest")search_request.customer_id=customer_idsearch_request.query=queryresults:SearchGoogleAdsResponse=ga_service.search(request=search_request)# Iterate over the results and build the list of conversion goals.forrowinresults:customer_conversion_goals.append({"category":row.customer_conversion_goal.category,"origin":row.customer_conversion_goal.origin,})returncustomer_conversion_goalsdefcreate_conversion_goal_operations(client:GoogleAdsClient,customer_id:str,customer_conversion_goals:List[Dict[str,Union[ConversionActionCategoryEnum.ConversionActionCategory,ConversionOriginEnum.ConversionOrigin,],]],)->List[MutateOperation]:"""Creates a list of MutateOperations that override customer conversion goals.Args:client: an initialized GoogleAdsClient instance.customer_id: a client customer ID.customer_conversion_goals: the list of customer conversion goals thatwill be overridden.Returns:MutateOperations that update campaign conversion goals."""campaign_conversion_goal_service:CampaignConversionGoalServiceClient=(client.get_service("CampaignConversionGoalService"))operations:List[MutateOperation]=[]# To override the customer conversion goals, we will change the# biddability of each of the customer conversion goals so that only# the desired conversion goal is biddable in this campaign.forcustomer_goal_dictincustomer_conversion_goals:mutate_operation:MutateOperation=client.get_type("MutateOperation")campaign_conversion_goal:CampaignConversionGoal=(mutate_operation.campaign_conversion_goal_operation.update)category_enum_value:(ConversionActionCategoryEnum.ConversionActionCategory)=customer_goal_dict["category"]origin_enum_value:ConversionOriginEnum.ConversionOrigin=(customer_goal_dict["origin"])campaign_conversion_goal.resource_name=(campaign_conversion_goal_service.campaign_conversion_goal_path(customer_id,_PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID,category_enum_value.name,origin_enum_value.name,))# Change the biddability for the campaign conversion goal.# Set biddability to True for the desired (category, origin).# Set biddability to False for all other conversion goals.# Note:# 1- It is assumed that this Conversion Action# (category=PURCHASE, origin=WEBSITE) exists in this account.# 2- More than one goal can be biddable if desired. This example# shows only one.if(category_enum_value==client.enums.ConversionActionCategoryEnum.PURCHASEandorigin_enum_value==client.enums.ConversionOriginEnum.WEBSITE):biddable=Trueelse:biddable=Falsecampaign_conversion_goal.biddable=biddablefield_mask=protobuf_helpers.field_mask(None,campaign_conversion_goal._pb)client.copy_from(mutate_operation.campaign_conversion_goal_operation.update_mask,field_mask,)operations.append(mutate_operation)returnoperations
def_get_customer_conversion_goals(client,customer_id)query=<<~EODSELECTcustomer_conversion_goal.category,customer_conversion_goal.originFROMcustomer_conversion_goalEODcustomer_conversion_goals=[]ga_service=client.service.google_ads# The number of conversion goals is typically less than 50 so we use# GoogleAdsService.search instead of search_stream.response=ga_service.search(customer_id:customer_id,query:query,)# Iterate over the results and build the list of conversion goals.response.eachdo|row|customer_conversion_goals<<{"category"=>row.customer_conversion_goal.category,"origin"=>row.customer_conversion_goal.origin}endcustomer_conversion_goalsenddefcreate_conversion_goal_operations(client,customer_id,customer_conversion_goals)campaign_conversion_goal_service=client.service.campaign_conversion_goaloperations=[]# To override the customer conversion goals, we will change the# biddability of each of the customer conversion goals so that only# the desired conversion goal is biddable in this campaign.customer_conversion_goals.eachdo|customer_conversion_goal|operations<<client.operation.mutatedo|m|m.campaign_conversion_goal_operation=client.operation.campaign_conversion_goaldo|op|op.update=client.resource.campaign_conversion_goaldo|ccg|ccg.resource_name=client.path.campaign_conversion_goal(customer_id,PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID,customer_conversion_goal["category"].to_s,customer_conversion_goal["origin"].to_s)# Change the biddability for the campaign conversion goal.# Set biddability to True for the desired (category, origin).# Set biddability to False for all other conversion goals.# Note:# 1- It is assumed that this Conversion Action# (category=PURCHASE, origin=WEBSITE) exists in this account.# 2- More than one goal can be biddable if desired. This example# shows only one.ccg.biddable=(customer_conversion_goal["category"]==:PURCHASE&&customer_conversion_goal["origin"]==:WEBSITE)endop.update_mask=Google::Ads::GoogleAds::FieldMaskUtil.all_set_fields_of(op.update)endendendoperationsend
subget_customer_conversion_goals{my($api_client,$customer_id)=@_;my$customer_conversion_goals=[];# Create a query that retrieves all customer conversion goals.my$query="SELECT customer_conversion_goal.category, customer_conversion_goal.origin "."FROM customer_conversion_goal";# The number of conversion goals is typically less than 50 so we use# GoogleAdsService->search() method instead of search_stream().my$search_response=$api_client->GoogleAdsService()->search({customerId=>$customer_id,query=>$query});# Iterate over the results and build the list of conversion goals.foreachmy$google_ads_row(@{$search_response->{results}}){push@$customer_conversion_goals,{category=>$google_ads_row->{customerConversionGoal}{category},origin=>$google_ads_row->{customerConversionGoal}{origin}};}return$customer_conversion_goals;}# Creates a list of MutateOperations that override customer conversion goals.subcreate_conversion_goal_operations{my($customer_id,$customer_conversion_goals)=@_;my$operations=[];# To override the customer conversion goals, we will change the biddability of# each of the customer conversion goals so that only the desired conversion goal# is biddable in this campaign.foreachmy$customer_conversion_goal(@$customer_conversion_goals){my$campaign_conversion_goal=Google::Ads::GoogleAds::V21::Resources::CampaignConversionGoal->new({resourceName=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::campaign_conversion_goal($customer_id,PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID,$customer_conversion_goal->{category},$customer_conversion_goal->{origin})});# Change the biddability for the campaign conversion goal.# Set biddability to true for the desired (category, origin).# Set biddability to false for all other conversion goals.# Note:# 1- It is assumed that this Conversion Action# (category=PURCHASE, origin=WEBSITE) exists in this account.# 2- More than one goal can be biddable if desired. This example# shows only one.if($customer_conversion_goal->{category}eqPURCHASE&&$customer_conversion_goal->{origin}eqWEBSITE){$campaign_conversion_goal->{biddable}="true";}else{$campaign_conversion_goal->{biddable}="false";}push@$operations,Google::Ads::GoogleAds::V21::Services::GoogleAdsService::MutateOperation->new({campaignConversionGoalOperation=>Google::Ads::GoogleAds::V21::Services::CampaignConversionGoalService::CampaignConversionGoalOperation->new({update=>$campaign_conversion_goal,# Set the update mask on the operation. Here the update mask will be# a list of all the fields that were set on the update object.updateMask=>all_set_fields_of($campaign_conversion_goal)})});}return$operations;}
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;}
defcreate_multiple_text_assets(client:GoogleAdsClient,customer_id:str,texts:List[str])->List[str]:"""Creates multiple text assets and returns the list of resource names.Args:client: an initialized GoogleAdsClient instance.customer_id: a client customer ID.texts: a list of strings, each of which will be used to create a textasset.Returns:asset_resource_names: a list of asset resource names."""# Here again we use the GoogleAdService to create multiple text# assets in a single request.googleads_service:GoogleAdsServiceClient=client.get_service("GoogleAdsService")operations:List[MutateOperation]=[]fortextintexts:mutate_operation:MutateOperation=client.get_type("MutateOperation")asset:Asset=mutate_operation.asset_operation.createasset.text_asset.text=textoperations.append(mutate_operation)# Send the operations in a single Mutate request.response:MutateGoogleAdsResponse=googleads_service.mutate(customer_id=customer_id,mutate_operations=operations,)asset_resource_names:List[str]=[]forresultinresponse.mutate_operation_responses:ifresult._pb.HasField("asset_result"):asset_resource_names.append(result.asset_result.resource_name)print_response_details(response)returnasset_resource_names
# Creates multiple text assets and returns the list of resource names.defcreate_multiple_text_assets(client,customer_id,texts)operations=texts.mapdo|text|client.operation.mutatedo|m|m.asset_operation=client.operation.create_resource.assetdo|asset|asset.text_asset=client.resource.text_assetdo|text_asset|text_asset.text=textendendendend# Send the operations in a single Mutate request.response=client.service.google_ads.mutate(customer_id:customer_id,mutate_operations:operations,)asset_resource_names=[]response.mutate_operation_responses.eachdo|result|ifresult.asset_resultasset_resource_names.append(result.asset_result.resource_name)endendprint_response_details(response)asset_resource_namesend
subcreate_multiple_text_assets{my($api_client,$customer_id,$texts)=@_;# Here again we use the GoogleAdService to create multiple text assets in a# single request.my$operations=[];foreachmy$text(@$texts){# Create a mutate operation for a text asset.push@$operations,Google::Ads::GoogleAds::V21::Services::GoogleAdsService::MutateOperation->new({assetOperation=>Google::Ads::GoogleAds::V21::Services::AssetService::AssetOperation->new({create=>Google::Ads::GoogleAds::V21::Resources::Asset->new({textAsset=>Google::Ads::GoogleAds::V21::Common::TextAsset->new({text=>$text})})})});}# Issue a mutate request to add all assets.my$mutate_google_ads_response=$api_client->GoogleAdsService()->mutate({customerId=>$customer_id,mutateOperations=>$operations});my$asset_resource_names=[];foreachmy$response(@{$mutate_google_ads_response->{mutateOperationResponses}}){push@$asset_resource_names,$response->{assetResult}{resourceName};}print_response_details($mutate_google_ads_response);return$asset_resource_names;}
Anasset groupis a
collection of assets centered on a theme or related to a target audience. The
asset group is used to assemble all of your ads and build an inventory for all
applicable ad formats for your advertising objective.Learn more about asset
groups.
Asset groups contain one or more final URLs. At least one final URL is required.
Use the URL that is most relevant to the conversion path for the given asset
group and campaign objectives.
defcreate_asset_group_operation(client:GoogleAdsClient,customer_id:str,headline_asset_resource_names:List[str],description_asset_resource_names:List[str],brand_guidelines_enabled:bool,)->List[MutateOperation]:"""Creates a list of MutateOperations that create a new asset_group.A temporary ID will be assigned to this asset group so that it canbe referenced by other objects being created in the same Mutate request.Args:client: an initialized GoogleAdsClient instance.customer_id: a client customer ID.headline_asset_resource_names: a list of headline resource names.description_asset_resource_names: a list of description resource names.brand_guidelines_enabled: a boolean value indicating if the campaign isenabled for brand guidelines.Returns:MutateOperations that create a new asset group and related assets."""asset_group_service:AssetGroupServiceClient=client.get_service("AssetGroupService")campaign_service:CampaignServiceClient=client.get_service("CampaignService")operations:List[MutateOperation]=[]# Create the AssetGroupmutate_operation:MutateOperation=client.get_type("MutateOperation")asset_group:AssetGroup=mutate_operation.asset_group_operation.createasset_group.name=f"Performance Max asset group #{uuid4()}"asset_group.campaign=campaign_service.campaign_path(customer_id,_PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID)asset_group.final_urls.append("http://www.example.com")asset_group.final_mobile_urls.append("http://www.example.com")asset_group.status=client.enums.AssetGroupStatusEnum.PAUSEDasset_group.resource_name=asset_group_service.asset_group_path(customer_id,_ASSET_GROUP_TEMPORARY_ID,)operations.append(mutate_operation)# For the list of required assets for a Performance Max campaign, see# https://developers.google.com/google-ads/api/docs/performance-max/assets# An AssetGroup is linked to an Asset by creating a new AssetGroupAsset# and providing:# the resource name of the AssetGroup# the resource name of the Asset# the field_type of the Asset in this AssetGroup.## To learn more about AssetGroups, see# https://developers.google.com/google-ads/api/docs/performance-max/asset-groups# Link the previously created multiple text assets.# Link the headline assets.forresource_nameinheadline_asset_resource_names:mutate_operation:MutateOperation=client.get_type("MutateOperation")asset_group_asset:AssetGroupAsset=(mutate_operation.asset_group_asset_operation.create)asset_group_asset.field_type=client.enums.AssetFieldTypeEnum.HEADLINEasset_group_asset.asset_group=asset_group_service.asset_group_path(customer_id,_ASSET_GROUP_TEMPORARY_ID,)asset_group_asset.asset=resource_nameoperations.append(mutate_operation)# Link the description assets.forresource_nameindescription_asset_resource_names:mutate_operation:MutateOperation=client.get_type("MutateOperation")asset_group_asset:AssetGroupAsset=(mutate_operation.asset_group_asset_operation.create)asset_group_asset.field_type=(client.enums.AssetFieldTypeEnum.DESCRIPTION)asset_group_asset.asset_group=asset_group_service.asset_group_path(customer_id,_ASSET_GROUP_TEMPORARY_ID,)asset_group_asset.asset=resource_nameoperations.append(mutate_operation)# Create and link the long headline text asset.mutate_operations:List[MutateOperation]=create_and_link_text_asset(client,customer_id,"Travel the World",client.enums.AssetFieldTypeEnum.LONG_HEADLINE,)operations.extend(mutate_operations)# Create and link the business name and logo asset.mutate_operations:List[MutateOperation]=create_and_link_brand_assets(client,customer_id,brand_guidelines_enabled,"Interplanetary Cruises","https://gaagl.page.link/bjYi","Marketing Logo",)operations.extend(mutate_operations)# Create and link the image assets.# Create and link the Marketing Image Asset.mutate_operations:List[MutateOperation]=create_and_link_image_asset(client,customer_id,"https://gaagl.page.link/Eit5",client.enums.AssetFieldTypeEnum.MARKETING_IMAGE,"Marketing Image",)operations.extend(mutate_operations)# Create and link the Square Marketing Image Asset.mutate_operations:List[MutateOperation]=create_and_link_image_asset(client,customer_id,"https://gaagl.page.link/bjYi",client.enums.AssetFieldTypeEnum.SQUARE_MARKETING_IMAGE,"Square Marketing Image",)operations.extend(mutate_operations)returnoperations
# Creates a list of MutateOperations that create a new asset_group.## A temporary ID will be assigned to this asset group so that it can# be referenced by other objects being created in the same Mutate request.defcreate_asset_group_operation(client,customer_id,headline_asset_resource_names,description_asset_resource_names,brand_guidelines_enabled)operations=[]# Create the AssetGroupoperations<<client.operation.mutatedo|m|m.asset_group_operation=client.operation.create_resource.asset_groupdo|ag|ag.name="Performance Max asset group#{SecureRandom.uuid}"ag.campaign=client.path.campaign(customer_id,PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID)ag.final_urls<<"http://www.example.com"ag.final_mobile_urls<<"http://www.example.com"ag.status=:PAUSEDag.resource_name=client.path.asset_group(customer_id,ASSET_GROUP_TEMPORARY_ID)endend# For the list of required assets for a Performance Max campaign, see# https://developers.google.com/google-ads/api/docs/performance-max/assets## An AssetGroup is linked to an Asset by creating a new AssetGroupAsset# and providing:# the resource name of the AssetGroup# the resource name of the Asset# the field_type of the Asset in this AssetGroup.## To learn more about AssetGroups, see# https://developers.google.com/google-ads/api/docs/performance-max/asset-groups# Link the previously created multiple text assets.# Link the headline assets.headline_asset_resource_names.eachdo|resource_name|operations<<client.operation.mutatedo|m|m.asset_group_asset_operation=client.operation.create_resource.asset_group_assetdo|aga|aga.field_type=:HEADLINEaga.asset_group=client.path.asset_group(customer_id,ASSET_GROUP_TEMPORARY_ID)aga.asset=resource_nameendendend# Link the description assets.description_asset_resource_names.eachdo|resource_name|operations<<client.operation.mutatedo|m|m.asset_group_asset_operation=client.operation.create_resource.asset_group_assetdo|aga|aga.field_type=:DESCRIPTIONaga.asset_group=client.path.asset_group(customer_id,ASSET_GROUP_TEMPORARY_ID)aga.asset=resource_nameendendend# Create and link the long headline text asset.operations+=create_and_link_text_asset(client,customer_id,"Travel the World",:LONG_HEADLINE)# Create and link the business name and logo asset.operations+=create_and_link_brand_assets(client,customer_id,brand_guidelines_enabled,"Interplanetary Cruises","https://gaagl.page.link/bjYi","Marketing Logo")# Create and link the image assets.# Create and link the Marketing Image Asset.operations+=create_and_link_image_asset(client,customer_id,"https://gaagl.page.link/Eit5",:MARKETING_IMAGE,"Marketing Image")# Create and link the Square Marketing Image Asset.operations+=create_and_link_image_asset(client,customer_id,"https://gaagl.page.link/bjYi",:SQUARE_MARKETING_IMAGE,"Square Marketing Image")operationsend
subcreate_asset_group_operations{my($customer_id,$headline_asset_resource_names,$description_asset_resource_names,$brand_guidelines_enabled)=@_;my$operations=[];# Create a mutate operation that creates an asset group operation.push@$operations,Google::Ads::GoogleAds::V21::Services::GoogleAdsService::MutateOperation->new({assetGroupOperation=>Google::Ads::GoogleAds::V21::Services::AssetGroupService::AssetGroupOperation->new({create=>Google::Ads::GoogleAds::V21::Resources::AssetGroup->new({resourceName=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::asset_group($customer_id,ASSET_GROUP_TEMPORARY_ID),name=>"Performance Max asset group #".uniqid(),campaign=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::campaign($customer_id,PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID),finalUrls=>["http://www.example.com"],finalMobileUrls=>["http://www.example.com"],status=>Google::Ads::GoogleAds::V21::Enums::AssetGroupStatusEnum::PAUSED})})});# For the list of required assets for a Performance Max campaign, see# https://developers.google.com/google-ads/api/docs/performance-max/assets.# An AssetGroup is linked to an Asset by creating a new AssetGroupAsset# and providing:# - the resource name of the AssetGroup# - the resource name of the Asset# - the fieldType of the Asset in this AssetGroup## To learn more about AssetGroups, see# https://developers.google.com/google-ads/api/docs/performance-max/asset-groups.# Link the previously created multiple text assets.# Link the headline assets.foreachmy$resource_name(@$headline_asset_resource_names){push@$operations,Google::Ads::GoogleAds::V21::Services::GoogleAdsService::MutateOperation->new({assetGroupAssetOperation=>Google::Ads::GoogleAds::V21::Services::AssetGroupAssetService::AssetGroupAssetOperation->new({create=>Google::Ads::GoogleAds::V21::Resources::AssetGroupAsset->new({asset=>$resource_name,assetGroup=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::asset_group($customer_id,ASSET_GROUP_TEMPORARY_ID),fieldType=>HEADLINE})})});}# Link the description assets.foreachmy$resource_name(@$description_asset_resource_names){push@$operations,Google::Ads::GoogleAds::V21::Services::GoogleAdsService::MutateOperation->new({assetGroupAssetOperation=>Google::Ads::GoogleAds::V21::Services::AssetGroupAssetService::AssetGroupAssetOperation->new({create=>Google::Ads::GoogleAds::V21::Resources::AssetGroupAsset->new({asset=>$resource_name,assetGroup=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::asset_group($customer_id,ASSET_GROUP_TEMPORARY_ID),fieldType=>DESCRIPTION})})});}# Create and link the long headline text asset.push@$operations,@{create_and_link_text_asset($customer_id,"Travel the World",LONG_HEADLINE)};# Create and link the business name and logo asset.push@$operations,@{create_and_link_brand_assets($customer_id,$brand_guidelines_enabled,"Interplanetary Cruises","https://gaagl.page.link/bjYi","Marketing Logo")};# Create and link the image assets.# Create and link the marketing image asset.push@$operations,@{create_and_link_image_asset($customer_id,"https://gaagl.page.link/Eit5",MARKETING_IMAGE,"Marketing Image")};# Create and link the square marketing image asset.push@$operations,@{create_and_link_image_asset($customer_id,"https://gaagl.page.link/bjYi",SQUARE_MARKETING_IMAGE,"Square Marketing Image")};return$operations;}
defcreate_asset_group_operation(client:GoogleAdsClient,customer_id:str,headline_asset_resource_names:List[str],description_asset_resource_names:List[str],brand_guidelines_enabled:bool,)->List[MutateOperation]:"""Creates a list of MutateOperations that create a new asset_group.A temporary ID will be assigned to this asset group so that it canbe referenced by other objects being created in the same Mutate request.Args:client: an initialized GoogleAdsClient instance.customer_id: a client customer ID.headline_asset_resource_names: a list of headline resource names.description_asset_resource_names: a list of description resource names.brand_guidelines_enabled: a boolean value indicating if the campaign isenabled for brand guidelines.Returns:MutateOperations that create a new asset group and related assets."""asset_group_service:AssetGroupServiceClient=client.get_service("AssetGroupService")campaign_service:CampaignServiceClient=client.get_service("CampaignService")operations:List[MutateOperation]=[]# Create the AssetGroupmutate_operation:MutateOperation=client.get_type("MutateOperation")asset_group:AssetGroup=mutate_operation.asset_group_operation.createasset_group.name=f"Performance Max asset group #{uuid4()}"asset_group.campaign=campaign_service.campaign_path(customer_id,_PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID)asset_group.final_urls.append("http://www.example.com")asset_group.final_mobile_urls.append("http://www.example.com")asset_group.status=client.enums.AssetGroupStatusEnum.PAUSEDasset_group.resource_name=asset_group_service.asset_group_path(customer_id,_ASSET_GROUP_TEMPORARY_ID,)operations.append(mutate_operation)# For the list of required assets for a Performance Max campaign, see# https://developers.google.com/google-ads/api/docs/performance-max/assets# An AssetGroup is linked to an Asset by creating a new AssetGroupAsset# and providing:# the resource name of the AssetGroup# the resource name of the Asset# the field_type of the Asset in this AssetGroup.## To learn more about AssetGroups, see# https://developers.google.com/google-ads/api/docs/performance-max/asset-groups# Link the previously created multiple text assets.# Link the headline assets.forresource_nameinheadline_asset_resource_names:mutate_operation:MutateOperation=client.get_type("MutateOperation")asset_group_asset:AssetGroupAsset=(mutate_operation.asset_group_asset_operation.create)asset_group_asset.field_type=client.enums.AssetFieldTypeEnum.HEADLINEasset_group_asset.asset_group=asset_group_service.asset_group_path(customer_id,_ASSET_GROUP_TEMPORARY_ID,)asset_group_asset.asset=resource_nameoperations.append(mutate_operation)# Link the description assets.forresource_nameindescription_asset_resource_names:mutate_operation:MutateOperation=client.get_type("MutateOperation")asset_group_asset:AssetGroupAsset=(mutate_operation.asset_group_asset_operation.create)asset_group_asset.field_type=(client.enums.AssetFieldTypeEnum.DESCRIPTION)asset_group_asset.asset_group=asset_group_service.asset_group_path(customer_id,_ASSET_GROUP_TEMPORARY_ID,)asset_group_asset.asset=resource_nameoperations.append(mutate_operation)# Create and link the long headline text asset.mutate_operations:List[MutateOperation]=create_and_link_text_asset(client,customer_id,"Travel the World",client.enums.AssetFieldTypeEnum.LONG_HEADLINE,)operations.extend(mutate_operations)# Create and link the business name and logo asset.mutate_operations:List[MutateOperation]=create_and_link_brand_assets(client,customer_id,brand_guidelines_enabled,"Interplanetary Cruises","https://gaagl.page.link/bjYi","Marketing Logo",)operations.extend(mutate_operations)# Create and link the image assets.# Create and link the Marketing Image Asset.mutate_operations:List[MutateOperation]=create_and_link_image_asset(client,customer_id,"https://gaagl.page.link/Eit5",client.enums.AssetFieldTypeEnum.MARKETING_IMAGE,"Marketing Image",)operations.extend(mutate_operations)# Create and link the Square Marketing Image Asset.mutate_operations:List[MutateOperation]=create_and_link_image_asset(client,customer_id,"https://gaagl.page.link/bjYi",client.enums.AssetFieldTypeEnum.SQUARE_MARKETING_IMAGE,"Square Marketing Image",)operations.extend(mutate_operations)returnoperations
# Creates a list of MutateOperations that create a new asset_group.## A temporary ID will be assigned to this asset group so that it can# be referenced by other objects being created in the same Mutate request.defcreate_asset_group_operation(client,customer_id,headline_asset_resource_names,description_asset_resource_names,brand_guidelines_enabled)operations=[]# Create the AssetGroupoperations<<client.operation.mutatedo|m|m.asset_group_operation=client.operation.create_resource.asset_groupdo|ag|ag.name="Performance Max asset group#{SecureRandom.uuid}"ag.campaign=client.path.campaign(customer_id,PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID)ag.final_urls<<"http://www.example.com"ag.final_mobile_urls<<"http://www.example.com"ag.status=:PAUSEDag.resource_name=client.path.asset_group(customer_id,ASSET_GROUP_TEMPORARY_ID)endend# For the list of required assets for a Performance Max campaign, see# https://developers.google.com/google-ads/api/docs/performance-max/assets## An AssetGroup is linked to an Asset by creating a new AssetGroupAsset# and providing:# the resource name of the AssetGroup# the resource name of the Asset# the field_type of the Asset in this AssetGroup.## To learn more about AssetGroups, see# https://developers.google.com/google-ads/api/docs/performance-max/asset-groups# Link the previously created multiple text assets.# Link the headline assets.headline_asset_resource_names.eachdo|resource_name|operations<<client.operation.mutatedo|m|m.asset_group_asset_operation=client.operation.create_resource.asset_group_assetdo|aga|aga.field_type=:HEADLINEaga.asset_group=client.path.asset_group(customer_id,ASSET_GROUP_TEMPORARY_ID)aga.asset=resource_nameendendend# Link the description assets.description_asset_resource_names.eachdo|resource_name|operations<<client.operation.mutatedo|m|m.asset_group_asset_operation=client.operation.create_resource.asset_group_assetdo|aga|aga.field_type=:DESCRIPTIONaga.asset_group=client.path.asset_group(customer_id,ASSET_GROUP_TEMPORARY_ID)aga.asset=resource_nameendendend# Create and link the long headline text asset.operations+=create_and_link_text_asset(client,customer_id,"Travel the World",:LONG_HEADLINE)# Create and link the business name and logo asset.operations+=create_and_link_brand_assets(client,customer_id,brand_guidelines_enabled,"Interplanetary Cruises","https://gaagl.page.link/bjYi","Marketing Logo")# Create and link the image assets.# Create and link the Marketing Image Asset.operations+=create_and_link_image_asset(client,customer_id,"https://gaagl.page.link/Eit5",:MARKETING_IMAGE,"Marketing Image")# Create and link the Square Marketing Image Asset.operations+=create_and_link_image_asset(client,customer_id,"https://gaagl.page.link/bjYi",:SQUARE_MARKETING_IMAGE,"Square Marketing Image")operationsend
subcreate_asset_group_operations{my($customer_id,$headline_asset_resource_names,$description_asset_resource_names,$brand_guidelines_enabled)=@_;my$operations=[];# Create a mutate operation that creates an asset group operation.push@$operations,Google::Ads::GoogleAds::V21::Services::GoogleAdsService::MutateOperation->new({assetGroupOperation=>Google::Ads::GoogleAds::V21::Services::AssetGroupService::AssetGroupOperation->new({create=>Google::Ads::GoogleAds::V21::Resources::AssetGroup->new({resourceName=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::asset_group($customer_id,ASSET_GROUP_TEMPORARY_ID),name=>"Performance Max asset group #".uniqid(),campaign=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::campaign($customer_id,PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID),finalUrls=>["http://www.example.com"],finalMobileUrls=>["http://www.example.com"],status=>Google::Ads::GoogleAds::V21::Enums::AssetGroupStatusEnum::PAUSED})})});# For the list of required assets for a Performance Max campaign, see# https://developers.google.com/google-ads/api/docs/performance-max/assets.# An AssetGroup is linked to an Asset by creating a new AssetGroupAsset# and providing:# - the resource name of the AssetGroup# - the resource name of the Asset# - the fieldType of the Asset in this AssetGroup## To learn more about AssetGroups, see# https://developers.google.com/google-ads/api/docs/performance-max/asset-groups.# Link the previously created multiple text assets.# Link the headline assets.foreachmy$resource_name(@$headline_asset_resource_names){push@$operations,Google::Ads::GoogleAds::V21::Services::GoogleAdsService::MutateOperation->new({assetGroupAssetOperation=>Google::Ads::GoogleAds::V21::Services::AssetGroupAssetService::AssetGroupAssetOperation->new({create=>Google::Ads::GoogleAds::V21::Resources::AssetGroupAsset->new({asset=>$resource_name,assetGroup=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::asset_group($customer_id,ASSET_GROUP_TEMPORARY_ID),fieldType=>HEADLINE})})});}# Link the description assets.foreachmy$resource_name(@$description_asset_resource_names){push@$operations,Google::Ads::GoogleAds::V21::Services::GoogleAdsService::MutateOperation->new({assetGroupAssetOperation=>Google::Ads::GoogleAds::V21::Services::AssetGroupAssetService::AssetGroupAssetOperation->new({create=>Google::Ads::GoogleAds::V21::Resources::AssetGroupAsset->new({asset=>$resource_name,assetGroup=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::asset_group($customer_id,ASSET_GROUP_TEMPORARY_ID),fieldType=>DESCRIPTION})})});}# Create and link the long headline text asset.push@$operations,@{create_and_link_text_asset($customer_id,"Travel the World",LONG_HEADLINE)};# Create and link the business name and logo asset.push@$operations,@{create_and_link_brand_assets($customer_id,$brand_guidelines_enabled,"Interplanetary Cruises","https://gaagl.page.link/bjYi","Marketing Logo")};# Create and link the image assets.# Create and link the marketing image asset.push@$operations,@{create_and_link_image_asset($customer_id,"https://gaagl.page.link/Eit5",MARKETING_IMAGE,"Marketing Image")};# Create and link the square marketing image asset.push@$operations,@{create_and_link_image_asset($customer_id,"https://gaagl.page.link/bjYi",SQUARE_MARKETING_IMAGE,"Square Marketing Image")};return$operations;}
AnAssetGroupSignalis a signal that you can
provide to Google to optimize ad serving at the asset group level. There are two
types of hints that you can provide to Google:
audience: A reusable
collection of focused segments, demographic targeting, and exclusions
search_theme: Information
about what your customers are searching for and which topics lead to
conversions for your business that you canprovide to Google AI
# Create a list of MutateOperations that create AssetGroupSignals.defcreate_asset_group_signal_operations(client,customer_id,audience_id)operations=[]returnoperationsifaudience_id.nil?operations<<client.operation.mutatedo|m|m.asset_group_signal_operation=client.operation.create_resource.asset_group_signaldo|ags|ags.asset_group=client.path.asset_group(customer_id,ASSET_GROUP_TEMPORARY_ID,)ags.audience=client.resource.audience_infodo|ai|ai.audience=client.path.audience(customer_id,audience_id)endendendoperationsend
subcreate_asset_group_signal_operations{my($customer_id,$audience_id)=@_;my$operations=[];return$operationsifnotdefined$audience_id;push@$operations,Google::Ads::GoogleAds::V21::Services::GoogleAdsService::MutateOperation->new({assetGroupSignalOperation=>Google::Ads::GoogleAds::V21::Services::AssetGroupSignalService::AssetGroupSignalOperation->new({# To learn more about Audience Signals, see:# https://developers.google.com/google-ads/api/docs/performance-max/asset-groups#audience_signalscreate=>Google::Ads::GoogleAds::V21::Resources::AssetGroupSignal->new({assetGroup=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::asset_group($customer_id,ASSET_GROUP_TEMPORARY_ID),audience=>Google::Ads::GoogleAds::V21::Common::AudienceInfo->new({audience=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::audience($customer_id,$audience_id)})})})});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 utilize Google AI to optimize across various channels for online sales or lead generation.\u003c/p\u003e\n"],["\u003cp\u003eThese campaigns require essential components like campaign budgets, campaigns, asset groups, and assets, which can be managed programmatically through the Google Ads API.\u003c/p\u003e\n"],["\u003cp\u003eConversion tracking setup is crucial for campaign performance and bidding strategy selection (Maximize Conversions or Maximize Conversion Value).\u003c/p\u003e\n"],["\u003cp\u003eAsset groups and their corresponding assets (text, images, etc.) must be created and linked together within the campaign for ad delivery.\u003c/p\u003e\n"],["\u003cp\u003eCampaign targeting options include location, language, and audience signals to refine ad reach and relevance.\u003c/p\u003e\n"]]],[],null,[]]