Campaign Budget AssignmentStay organized with collectionsSave and categorize content based on your preferences.
AI-generated Key Takeaways
A budget can be assigned to a new campaign or an existing campaign using thecampaign_budgetfield with the budget's resource name in theCampaignOperation.createorCampaignOperation.updaterespectively.
When assigning a budget to an existing campaign, the new budget replaces the old one, and it is generally best practice to update an existing budget rather than create a new one to avoid potential overdelivery and ignoring past spend.
Although a campaign must always have a budget, you can effectively dissociate a budget by replacing it with another budget.
You can retrieve all campaigns assigned to a specific budget by querying thecampaignresource and filtering bycampaign_budget.id.
You can assign a budget to a campaign, dissociate a budget from a campaign, or
retrieve the campaigns that are assigned to a specific budget.
# Create campaign.campaign_operation:CampaignOperation=client.get_type("CampaignOperation")campaign:Campaign=campaign_operation.createcampaign.name=f"Interplanetary Cruise{uuid.uuid4()}"campaign.advertising_channel_type=(client.enums.AdvertisingChannelTypeEnum.SEARCH)# Recommendation: Set the campaign to PAUSED when creating it to prevent# the ads from immediately serving. Set to ENABLED once you've added# targeting and the ads are ready to serve.campaign.status=client.enums.CampaignStatusEnum.PAUSED# Set the bidding strategy and budget.campaign.manual_cpc=client.get_type("ManualCpc")campaign.campaign_budget=campaign_budget_response.results[0].resource_name# Set the campaign network options.campaign.network_settings.target_google_search=Truecampaign.network_settings.target_search_network=Truecampaign.network_settings.target_partner_search_network=False# Enable Display Expansion on Search campaigns. For more details see:# https://support.google.com/google-ads/answer/7193800campaign.network_settings.target_content_network=True# 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: Set the start date.start_time:datetime.date=datetime.date.today()+datetime.timedelta(days=1)campaign.start_date=datetime.date.strftime(start_time,_DATE_FORMAT)# Optional: Set the end date.end_time:datetime.date=start_time+datetime.timedelta(weeks=4)campaign.end_date=datetime.date.strftime(end_time,_DATE_FORMAT)
# Create campaign.campaign=client.resource.campaigndo|c|c.name="Interplanetary Cruise#{(Time.new.to_f*1000).to_i}"c.advertising_channel_type=:SEARCH# Recommendation: Set the campaign to PAUSED when creating it to prevent# the ads from immediately serving. Set to ENABLED once you've added# targeting and the ads are ready to serve.c.status=:PAUSED# Set the bidding strategy and budget.c.manual_cpc=client.resource.manual_cpcc.campaign_budget=return_budget.results.first.resource_name# Set the campaign network options.c.network_settings=client.resource.network_settingsdo|ns|ns.target_google_search=truens.target_search_network=true# Enable Display Expansion on Search campaigns. See# https://support.google.com/google-ads/answer/7193800 to learn more.ns.target_content_network=truens.target_partner_search_network=falseend# 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: Set the start date.c.start_date=DateTime.parse((Date.today+1).to_s).strftime('%Y%m%d')# Optional: Set the end date.c.end_date=DateTime.parse((Date.today.next_year).to_s).strftime('%Y%m%d')end
# Create a campaign.my$campaign=Google::Ads::GoogleAds::V22::Resources::Campaign->new({name=>"Interplanetary Cruise #".uniqid(),advertisingChannelType=>SEARCH,# Recommendation: Set the campaign to PAUSED when creating it to stop# the ads from immediately serving. Set to ENABLED once you've added# targeting and the ads are ready to serve.status=>PAUSED,# Set the bidding strategy and budget.manualCpc=>Google::Ads::GoogleAds::V22::Common::ManualCpc->new(),campaignBudget=>$campaign_budgets_response->{results}[0]{resourceName},# Set the campaign network options.networkSettings=>Google::Ads::GoogleAds::V22::Resources::NetworkSettings->new({targetGoogleSearch=>"true",targetSearchNetwork=>"true",# Enable Display Expansion on Search campaigns. See# https://support.google.com/google-ads/answer/7193800 to learn more.targetContentNetwork=>"true",targetPartnerSearchNetwork=>"false"}),# 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,# Optional: Set the start date. The campaign starts tomorrow.startDate=>strftime("%Y%m%d",localtime(time+60*60*24)),# Optional: Set the end date. The campaign runs for 30 days.endDate=>strftime("%Y%m%d",localtime(time+60*60*24*30)),});
To replace the budget of an existing campaign, in aCampaignOperation.update,
set thecampaign_budgetfield
of theCampaignobject to
the resource name of an existing budget (along with any other campaign
fields that you might want to set). Note that this will replace the existing
budget assigned to the campaign with the one specified by thecampaign_budgetfield, since a campaign can be associated with only one budget at a time.
Dissociate a budget from a campaign
A campaign must always be associated with a budget. You can remove a budget
from a campaign by changing the budget associated with the campaign, therebyreplacing it with another budget. To identify campaigns
using a particular budget, continue to the next section.
Retrieve campaigns assigned to a budget
Obtaining the list of campaigns that use the same budget can be helpful in
balancing budget utilization. The following GAQL query will return
all campaigns for the specified budget ID:
[[["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-11-05 UTC."],[],[]]