AI-generated Key Takeaways
-
When creating a new CampaignBudget using the Google Ads API, you can specify if it's shareable across campaigns using the
explicitly_sharedfield, withtrueallowing sharing andfalserestricting it to one campaign. -
Once a budget is created, you cannot change
explicitly_sharedfromtruetofalse, but you can change it fromfalsetotrueif no experiments are running on the associated campaign. -
Explicitly shared budgets appear in the Google Ads UI's Shared Library, while non-shared budgets only appear within their associated campaign's Settings.
-
You can determine if a campaign budget is shared by retrieving the
campaign_budget.explicitly_sharedfield using a GAQL query filtered by the budget ID.
A budget can be applied to a single campaign, or be shared across many campaigns.
Setup
When you create
a new CampaignBudget
using the Google Ads API, you can
specify if it is shareable with the BoolValue
of the explicitly_shared
field:
-
true(default): can be shared among multiple campaigns -
false: can be used by only one campaign
Explicitly shared budgets appear in an account's Shared Libraryin the Google Ads UI, whereas a non-shared budget appears only within its associated campaign's Settings.
In the following example where a new budget is created, the budget is shared
because explicitly_shared
is set to true
.
Java
private String createSharedCampaignBudget ( GoogleAdsClient googleAdsClient , long customerId ) { try ( CampaignBudgetServiceClient campaignBudgetServiceClient = googleAdsClient . getLatestVersion (). createCampaignBudgetServiceClient ()) { // Creates a shared budget. CampaignBudget budget = CampaignBudget . newBuilder () . setName ( "Shared Interplanetary Budget #" + getPrintableDateTime ()) . setAmountMicros ( 50_000_000L ) . setDeliveryMethod ( BudgetDeliveryMethod . STANDARD ) . setExplicitlyShared ( true ) . build (); // Constructs an operation that will create a shared budget. CampaignBudgetOperation operation = CampaignBudgetOperation . newBuilder (). setCreate ( budget ). build (); // Sends the operation in a mutate request. MutateCampaignBudgetsResponse response = campaignBudgetServiceClient . mutateCampaignBudgets ( Long . toString ( customerId ), Lists . newArrayList ( operation )); MutateCampaignBudgetResult mutateCampaignBudgetResult = response . getResults ( 0 ); // Prints the resource name of the created object. System . out . printf ( "Created shared budget with resource name: '%s'.%n" , mutateCampaignBudgetResult . getResourceName ()); return mutateCampaignBudgetResult . getResourceName (); } }
C#
private string CreateSharedBudget ( GoogleAdsClient client , long customerId , string name , long amount ) { // Get the CampaignBudgetService. CampaignBudgetServiceClient campaignBudgetService = client . GetService ( Services . V22 . CampaignBudgetService ); // Create a shared budget. CampaignBudget budget = new CampaignBudget () { Name = name , AmountMicros = amount , DeliveryMethod = BudgetDeliveryMethodEnum . Types . BudgetDeliveryMethod . Standard , ExplicitlyShared = true }; // Create the operation. CampaignBudgetOperation campaignBudgetOperation = new CampaignBudgetOperation () { Create = budget }; // Make the mutate request. MutateCampaignBudgetsResponse retVal = campaignBudgetService . MutateCampaignBudgets ( customerId . ToString (), new CampaignBudgetOperation [] { campaignBudgetOperation }); return retVal . Results [ 0 ]. ResourceName ; }
PHP
private static function createSharedCampaignBudget( GoogleAdsClient $googleAdsClient, int $customerId ) { // Creates a shared budget. $budget = new CampaignBudget([ 'name' => 'Shared Interplanetary Budget #' . Helper::getPrintableDatetime(), 'delivery_method' => BudgetDeliveryMethod::STANDARD, // Sets the amount of budget. 'amount_micros' => 50000000, // Makes the budget explicitly shared. 'explicitly_shared' => true ]); // Constructs a campaign budget operation. $campaignBudgetOperation = new CampaignBudgetOperation(); $campaignBudgetOperation->setCreate($budget); // Issues a mutate request to create the budget. $campaignBudgetServiceClient = $googleAdsClient->getCampaignBudgetServiceClient(); $response = $campaignBudgetServiceClient->mutateCampaignBudgets( MutateCampaignBudgetsRequest::build($customerId, [$campaignBudgetOperation]) ); /** @var CampaignBudget $addedBudget */ $addedBudget = $response->getResults()[0]; printf( "Created a shared budget with resource name '%s'.%s", $addedBudget->getResourceName(), PHP_EOL ); return $addedBudget->getResourceName(); }

