If you aren't tracking values and care about all of your conversions equally,
use theMaximizeConversionsbidding
strategy. An optionaltarget
CPA(cost-per-action) can be
set.Learn more.
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})})});}
Brand guidelinescontrol how
your brand is represented in your Performance Max campaign automated assets or
formats. From Google Ads API v21, Performance Max campaigns automatically enable brand
guidelines on all new Performance Max for online sales or lead generation
(standard) and Performance Max for online sales with a product feed (retail)
campaigns. If you don't want to enable brand guidelines on your new campaigns,
setCampaign.brand_guidelines_enabledtofalsewhen creating your new Performance Max campaign.
Performance Max campaigns with brand guidelines enabled use campaign-level
assets for brand asset field types(BUSINESS_NAME,LOGO, andLANDSCAPE_LOGO).
You must link brand assets to the campaign usingCampaignAssetand the
campaign must have:
Exactly oneBUSINESS_NAMEasset
At least oneLOGOasset and up to four optional additional logo assets of
the typeLOGOorLANDSCAPE_LOGO
Optional color and font guidelines for the campaign can be set using theCampaign.brand_guidelinesfield:
main_colorsets the
primary color. The color must be provided as a hex code string
(e.g., #00ff00).
accent_colorsets the
secondary color. The color must be provided as a hex code string
(e.g., #00ff00).
Starting on June 1, 2025, we will begin toautomatically enable brand
guidelinesfor Performance Max campaigns that use the same brand assets (BUSINESS_NAME,LOGO, andLANDSCAPE_LOGO) across all asset groups. All campaigns that can be
automatically migrated will be migrated by October 30, 2025.
Automatic migration will only occur for campaigns that use a consistent
business name and logo in every asset group. If your campaign has variations
in these assets, it won't be migrated automatically.
All eligible Performance Max campaigns under a customer ID will be migrated
simultaneously.
After migration, each migrated campaign will have its own set of brand
assets stored at the campaign level usingCampaignAsset.
Campaigns not eligible for automatic migration require manual migration to
enable brand guidelines.
Campaign.brand_guidelines_enabledindicates if an existing campaign is enabled for brand guidelines. To manually
enable brand guidelines for an existing campaign, useCampaignService.EnablePMaxBrandGuidelinesinstead of updating thebrand_guidelines_enabledfield directly, as the field
is immutable. Setauto_populate_brand_assetstotrueto automatically populate the campaign with top-performing brand
assets. Otherwise, you must manually provide the assets in the operation withbrand_assets. Disabling brand
guidelines for a campaign is not supported.
Optional: Final URL expansion
URL expansionhelps you
optimize the performance of your Performance Max campaigns. Use URL expansion to
replace your final URL with a more relevant landing page and dynamic headline
based on customers' intent. By default, URL expansion is:
[[["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 are created with the \u003ccode\u003ePERFORMANCE_MAX\u003c/code\u003e advertising channel type and initially set to \u003ccode\u003ePAUSED\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eBidding strategies for Performance Max include \u003ccode\u003eMaximizeConversions\u003c/code\u003e and \u003ccode\u003eMaximizeConversionValue\u003c/code\u003e, chosen based on whether conversions are value-tracked.\u003c/p\u003e\n"],["\u003cp\u003eURL expansion is enabled by default, allowing targeting of the entire domain, but can be customized to target specific URLs or exclude others.\u003c/p\u003e\n"],["\u003cp\u003eThe Google Ads API provides code examples in various languages (Java, C#, PHP, Python, Ruby) to automate campaign creation and management.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Ads API offers recommendations to optimize bidding, such as using \u003ccode\u003eMAXIMIZE_CONVERSION_VALUE_OPT_IN\u003c/code\u003e or \u003ccode\u003eMAXIMIZE_CONVERSIONS_OPT_IN\u003c/code\u003e with a suggested budget.\u003c/p\u003e\n"]]],[],null,[]]