Cross-account Bidding Strategies

Cross-account bidding strategies are effectively Smart Bidding portfolio bidding strategies created in manager accounts. They can be used by campaigns in any client account beneath the manager that owns the strategy.

Create and manage

Creating a new cross-account bidding strategy is almost identical to creating a new portfolio bidding strategy, except you set the customer_id of the API call to that of a manager account. Use a manager account's ID to create a new BiddingStrategy resource, the same way you would create a new portfolio strategy in a client account.

Java

 private 
  
 String 
  
 createBiddingStrategy 
 ( 
 GoogleAdsClient 
  
 googleAdsClient 
 , 
  
 long 
  
 managerCustomerId 
 ) 
  
 { 
  
 try 
  
 ( 
 BiddingStrategyServiceClient 
  
 biddingStrategyServiceClient 
  
 = 
  
 googleAdsClient 
 . 
 getLatestVersion 
 (). 
 createBiddingStrategyServiceClient 
 ()) 
  
 { 
  
 // Creates a portfolio bidding strategy. 
  
 BiddingStrategy 
  
 portfolioBiddingStrategy 
  
 = 
  
 BiddingStrategy 
 . 
 newBuilder 
 () 
  
 . 
 setName 
 ( 
 "Maximize Clicks #" 
  
 + 
  
 getPrintableDateTime 
 ()) 
  
 . 
 setTargetSpend 
 ( 
 TargetSpend 
 . 
 getDefaultInstance 
 ()) 
  
 // Sets the currency of the new bidding strategy. If not provided, the bidding 
  
 // strategy uses the manager account's default currency. 
  
 . 
 setCurrencyCode 
 ( 
 "USD" 
 ) 
  
 . 
 build 
 (); 
  
 // Constructs an operation that will create a portfolio bidding strategy. 
  
 BiddingStrategyOperation 
  
 operation 
  
 = 
  
 BiddingStrategyOperation 
 . 
 newBuilder 
 (). 
 setCreate 
 ( 
 portfolioBiddingStrategy 
 ). 
 build 
 (); 
  
 // Sends the operation in a mutate request. 
  
 MutateBiddingStrategiesResponse 
  
 response 
  
 = 
  
 biddingStrategyServiceClient 
 . 
 mutateBiddingStrategies 
 ( 
  
 Long 
 . 
 toString 
 ( 
 managerCustomerId 
 ), 
  
 ImmutableList 
 . 
 of 
 ( 
 operation 
 )); 
  
 // Prints the resource name of the created cross-account bidding strategy. 
  
 MutateBiddingStrategyResult 
  
 mutateBiddingStrategyResult 
  
 = 
  
 response 
 . 
 getResults 
 ( 
 0 
 ); 
  
 String 
  
 resourceName 
  
 = 
  
 mutateBiddingStrategyResult 
 . 
 getResourceName 
 (); 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "Created cross-account bidding strategy: '%s'.%n" 
 , 
  
 resourceName 
 ); 
  
 return 
  
 resourceName 
 ; 
  
 } 
 } 
  
  

C#

 /// <summary> 
 /// Creates a new TargetSpend (Maximize Clicks) cross-account bidding strategy in the 
 /// specified manager account. 
 /// </summary> 
 /// <param name="client">The Google Ads client.</param> 
 /// <param name="managerCustomerId">The manager customer ID.</param> 
 /// <returns>The resource name of the newly created bidding strategy.</returns> 
 private 
  
 string 
  
 CreateBiddingStrategy 
 ( 
 GoogleAdsClient 
  
 client 
 , 
  
 long 
  
 managerCustomerId 
 ) 
 { 
  
 BiddingStrategyServiceClient 
  
 biddingStrategyServiceClient 
  
 = 
  
 client 
 . 
 GetService 
 ( 
 Services 
 . 
 V21 
 . 
 BiddingStrategyService 
 ); 
  
 // Create a portfolio bidding strategy. 
  
 BiddingStrategy 
  
 portfolioBiddingStrategy 
  
 = 
  
 new 
  
 BiddingStrategy 
  
 { 
  
 Name 
  
 = 
  
 $"Maximize clicks #{ExampleUtilities.GetRandomString()}" 
 , 
  
 TargetSpend 
  
 = 
  
 new 
  
 TargetSpend 
 (), 
  
 // Set the currency of the new bidding strategy. If not provided, the bidding 
  
 // strategy uses the manager account's default currency. 
  
 CurrencyCode 
  
 = 
  
 "USD" 
  
 }; 
  
 // Send a create operation that will create the portfolio bidding strategy. 
  
 MutateBiddingStrategiesResponse 
  
 mutateBiddingStrategiesResponse 
  
 = 
  
 biddingStrategyServiceClient 
 . 
 MutateBiddingStrategies 
 ( 
 managerCustomerId 
 . 
 ToString 
 (), 
  
 new 
 [] 
  
 { 
  
 new 
  
 BiddingStrategyOperation 
  
 { 
  
 Create 
  
 = 
  
 portfolioBiddingStrategy 
  
 } 
  
 }); 
  
 // Print and return the resource name of the newly created cross-account bidding 
  
 // strategy. 
  
 string 
  
 biddingStrategyResourceName 
  
 = 
  
 mutateBiddingStrategiesResponse 
 . 
 Results 
 . 
 First 
 (). 
 ResourceName 
 ; 
  
 Console 
 . 
 WriteLine 
 ( 
 "Created cross-account bidding strategy " 
  
 + 
  
 $"'{biddingStrategyResourceName}'." 
 ); 
  
 return 
  
 biddingStrategyResourceName 
 ; 
 } 
  
  

PHP

 private static function createBiddingStrategy( 
 GoogleAdsClient $googleAdsClient, 
 int $managerCustomerId 
 ): string { 
 // Creates a portfolio bidding strategy. 
 $portfolioBiddingStrategy = new BiddingStrategy([ 
 'name' => 'Maximize Clicks #' . Helper::getPrintableDatetime(), 
 'target_spend' => new TargetSpend(), 
 // Optional: Sets the currency of the new bidding strategy to match the currency of the 
 // client account with which this bidding strategy is shared. 
 // If not provided, the bidding strategy uses the manager account's default currency. 
 'currency_code' => 'USD' 
 ]); 
 // Constructs an operation that will create a portfolio bidding strategy. 
 $biddingStrategyOperation = new BiddingStrategyOperation(); 
 $biddingStrategyOperation->setCreate($portfolioBiddingStrategy); 
 // Issues a mutate request to create the bidding strategy. 
 $biddingStrategyServiceClient = $googleAdsClient->getBiddingStrategyServiceClient(); 
 $response = $biddingStrategyServiceClient->mutateBiddingStrategies( 
 MutateBiddingStrategiesRequest::build($managerCustomerId, [$biddingStrategyOperation]) 
 ); 
 /** @var BiddingStrategy $addedBiddingStrategy */ 
 $addedBiddingStrategy = $response->getResults()[0]; 
 // Prints out the resource name of the created bidding strategy. 
 printf( 
 "Created cross-account bidding strategy with resource name: '%s'.%s", 
 $addedBiddingStrategy->getResourceName(), 
 PHP_EOL 
 ); 
 return $addedBiddingStrategy->getResourceName(); 
 }  
 

Python

 def 
  
 create_bidding_strategy 
 ( 
 client 
 : 
 GoogleAdsClient 
 , 
 manager_customer_id 
 : 
 str 
 ) 
 - 
> str 
 : 
  
 """Creates a new cross-account bidding strategy in the manager account. 
 The cross-account bidding strategy is of type TargetSpend (Maximize Clicks). 
 Args: 
 client: An initialized GoogleAdsClient instance. 
 manager_customer_id: A manager customer ID. 
 Returns: 
 The ID of the newly created bidding strategy. 
 """ 
 bidding_strategy_service 
 : 
 BiddingStrategyServiceClient 
 = 
 client 
 . 
 get_service 
 ( 
 "BiddingStrategyService" 
 ) 
 # Creates a portfolio bidding strategy. 
 # Constructs an operation that will create a portfolio bidding strategy. 
 bidding_strategy_operation 
 : 
 BiddingStrategyOperation 
 = 
 client 
 . 
 get_type 
 ( 
 "BiddingStrategyOperation" 
 ) 
 bidding_strategy 
 : 
 BiddingStrategy 
 = 
 bidding_strategy_operation 
 . 
 create 
 bidding_strategy 
 . 
 name 
 = 
 f 
 "Maximize Clicks # 
 { 
 uuid4 
 () 
 } 
 " 
 # Sets target_spend to an empty TargetSpend object without setting any 
 # of its nested fields. 
 bidding_strategy 
 . 
 target_spend 
 = 
 client 
 . 
 get_type 
 ( 
 "TargetSpend" 
 ) 
 # Sets the currency of the new bidding strategy. If not provided, the 
 # bidding strategy uses the manager account's default currency. 
 bidding_strategy 
 . 
 currency_code 
 = 
 "USD" 
 # Sends the operation in a mutate request. 
 response 
 : 
 MutateBiddingStrategiesResponse 
 = 
 ( 
 bidding_strategy_service 
 . 
 mutate_bidding_strategies 
 ( 
 customer_id 
 = 
 manager_customer_id 
 , 
 operations 
 = 
 [ 
 bidding_strategy_operation 
 ], 
 ) 
 ) 
 # Prints the resource name of the created cross-account bidding strategy. 
 resource_name 
 : 
 str 
 = 
 response 
 . 
 results 
 [ 
 0 
 ] 
 . 
 resource_name 
 print 
 ( 
 f 
 "Created cross-account bidding strategy: ' 
 { 
 resource_name 
 } 
 '" 
 ) 
 return 
 resource_name  
 
 . 
 py 

Ruby

 def 
  
 create_bidding_strategy 
 ( 
 client 
 , 
  
 manager_customer_id 
 ) 
  
 # Constructs an operation that will create a portfolio bidding strategy. 
  
 operation 
  
 = 
  
 client 
 . 
 operation 
 . 
 create_resource 
 . 
 bidding_strategy 
  
 do 
  
 | 
 b 
 | 
  
 b 
 . 
 name 
  
 = 
  
 "Maximize Clicks # 
 #{ 
 ( 
 Time 
 . 
 new 
 . 
 to_f 
  
 * 
  
 1000 
 ) 
 . 
 to_i 
 } 
 " 
  
 b 
 . 
 target_spend 
  
 = 
  
 client 
 . 
 resource 
 . 
 target_spend 
  
 # Sets the currency of the new bidding strategy. If not provided, the 
  
 # bidding strategy uses the manager account's default currency. 
  
 b 
 . 
 currency_code 
  
 = 
  
 "USD" 
  
 end 
  
 # Sends the operation in a mutate request. 
  
 response 
  
 = 
  
 client 
 . 
 service 
 . 
 bidding_strategy 
 . 
 mutate_bidding_strategies 
 ( 
  
 customer_id 
 : 
  
 manager_customer_id 
 , 
  
 operations 
 : 
  
 [ 
 operation 
 ] 
 , 
  
 ) 
  
 resource_name 
  
 = 
  
 response 
 . 
 results 
 . 
 first 
 . 
 resource_name 
  
 puts 
  
 "Created cross-account bidding strategy: ` 
 #{ 
 resource_name 
 } 
 `" 
  
 resource_name 
 end  
 
 . 
 rb 
  

Perl

 # Creates a new TargetSpend (Maximize Clicks) cross-account bidding strategy in 
 # the specified manager account. 
 sub 
  
 _create_bidding_strategy 
  
 { 
  
 my 
  
 ( 
 $api_client 
 , 
  
 $manager_customer_id 
 ) 
  
 = 
  
 @_ 
 ; 
  
 # Create a portfolio bidding strategy. 
  
 my 
  
 $portfolio_bidding_strategy 
  
 = 
  
 Google::Ads::GoogleAds::V21::Resources:: 
 BiddingStrategy 
 - 
> new 
 ({ 
  
 name 
  
 = 
>  
 "Maximize clicks #" 
  
 . 
  
 uniqid 
 (), 
  
 targetSpend 
  
 = 
>  
 Google::Ads::GoogleAds::V21::Common:: 
 TargetSpend 
 - 
> new 
 (), 
  
 # Sets the currency of the new bidding strategy. If not provided, the 
  
 # bidding strategy uses the manager account's default currency. 
  
 currencyCode 
  
 = 
>  
 "USD" 
  
 }); 
  
 # Send a create operation that will create the portfolio bidding strategy. 
  
 my 
  
 $mutate_bidding_strategies_response 
  
 = 
  
 $api_client 
 - 
> BiddingStrategyService 
 () 
 - 
> mutate 
 ({ 
  
 customerId 
  
 = 
>  
 $manager_customer_id 
 , 
  
 operations 
  
 = 
>  
 [ 
  
 Google::Ads::GoogleAds::V21::Services::BiddingStrategyService:: 
 BiddingStrategyOperation 
  
 - 
> new 
 ({ 
  
 create 
  
 = 
>  
 $portfolio_bidding_strategy 
  
 })]}); 
  
 my 
  
 $resource_name 
  
 = 
  
 $mutate_bidding_strategies_response 
 - 
> { 
 results 
 }[ 
 0 
 ]{ 
 resourceName 
 }; 
  
 printf 
  
 "Created cross-account bidding strategy with resource name '%s'.\n" 
 , 
  
 $resource_name 
 ; 
  
 return 
  
 $resource_name 
 ; 
 } 
  
  

Set the currency code

Cross-account strategies in manager accounts support setting an optional currency_code , allowing them to share bidding strategies with client accounts in different currencies. The field is optional, and if not set will default to the manager account's currency. The currency_code field is only mutable on cross-account bidding strategies.

Java

 BiddingStrategy 
  
 portfolioBiddingStrategy 
  
 = 
  
 BiddingStrategy 
 . 
 newBuilder 
 () 
  
 . 
 setName 
 ( 
 "Maximize Clicks #" 
  
 + 
  
 getPrintableDateTime 
 ()) 
  
 . 
 setTargetSpend 
 ( 
 TargetSpend 
 . 
 getDefaultInstance 
 ()) 
  
 // Sets the currency of the new bidding strategy. If not provided, the bidding 
  
 // strategy uses the manager account's default currency. 
  
 . 
 setCurrencyCode 
 ( 
 "USD" 
 ) 
  
 . 
 build 
 (); 
  
  

C#

 BiddingStrategy 
  
 portfolioBiddingStrategy 
  
 = 
  
 new 
  
 BiddingStrategy 
 { 
  
 Name 
  
 = 
  
 $"Maximize clicks #{ExampleUtilities.GetRandomString()}" 
 , 
  
 TargetSpend 
  
 = 
  
 new 
  
 TargetSpend 
 (), 
  
 // Set the currency of the new bidding strategy. If not provided, the bidding 
  
 // strategy uses the manager account's default currency. 
  
 CurrencyCode 
  
 = 
  
 "USD" 
 }; 
  
  

PHP

 $portfolioBiddingStrategy = new BiddingStrategy([ 
 'name' => 'Maximize Clicks #' . Helper::getPrintableDatetime(), 
 'target_spend' => new TargetSpend(), 
 // Optional: Sets the currency of the new bidding strategy to match the currency of the 
 // client account with which this bidding strategy is shared. 
 // If not provided, the bidding strategy uses the manager account's default currency. 
 'currency_code' => 'USD' 
 ]);  
 

Python

 # Constructs an operation that will create a portfolio bidding strategy. 
 bidding_strategy_operation 
 : 
 BiddingStrategyOperation 
 = 
 client 
 . 
 get_type 
 ( 
 "BiddingStrategyOperation" 
 ) 
 bidding_strategy 
 : 
 BiddingStrategy 
 = 
 bidding_strategy_operation 
 . 
 create 
 bidding_strategy 
 . 
 name 
 = 
 f 
 "Maximize Clicks # 
 { 
 uuid4 
 () 
 } 
 " 
 # Sets target_spend to an empty TargetSpend object without setting any 
 # of its nested fields. 
 bidding_strategy 
 . 
 target_spend 
 = 
 client 
 . 
 get_type 
 ( 
 "TargetSpend" 
 ) 
 # Sets the currency of the new bidding strategy. If not provided, the 
 # bidding strategy uses the manager account's default currency. 
 bidding_strategy 
 . 
 currency_code 
 = 
 "USD" 
  

Ruby

 operation 
  
 = 
  
 client 
 . 
 operation 
 . 
 create_resource 
 . 
 bidding_strategy 
  
 do 
  
 | 
 b 
 | 
  
 b 
 . 
 name 
  
 = 
  
 "Maximize Clicks # 
 #{ 
 ( 
 Time 
 . 
 new 
 . 
 to_f 
  
 * 
  
 1000 
 ) 
 . 
 to_i 
 } 
 " 
  
 b 
 . 
 target_spend 
  
 = 
  
 client 
 . 
 resource 
 . 
 target_spend 
  
 # Sets the currency of the new bidding strategy. If not provided, the 
  
 # bidding strategy uses the manager account's default currency. 
  
 b 
 . 
 currency_code 
  
 = 
  
 "USD" 
  
  

Perl

 my 
  
 $portfolio_bidding_strategy 
  
 = 
  
 Google::Ads::GoogleAds::V21::Resources:: 
 BiddingStrategy 
 - 
> new 
 ({ 
  
 name 
  
 = 
>  
 "Maximize clicks #" 
  
 . 
  
 uniqid 
 (), 
  
 targetSpend 
  
 = 
>  
 Google::Ads::GoogleAds::V21::Common:: 
 TargetSpend 
 - 
> new 
 (), 
  
 # Sets the currency of the new bidding strategy. If not provided, the 
  
 # bidding strategy uses the manager account's default currency. 
  
 currencyCode 
  
 = 
>  
 "USD" 
  
 }); 
  
  

Update strategies

Some fields of a bidding strategy can be updated, depending on its type . Manager accounts that own a bidding strategy (or their managers) can update the fields of a coss-account bidding strategy similarly to any other portfolio strategy .

For example, to change the maximum bid limit for the TargetSpend strategy created in the previous example, set its cpc_bid_ceiling_micros field to a new value.

Remove unused strategies

To remove a cross-account bidding strategy, it must not be in use by any campaigns. Attempting to remove a strategy that is still in use will result in a CANNOT_REMOVE_ASSOCIATED_STRATEGY error. You must first remove the strategy from any associated campaigns.

Read attributes

The BiddingStrategy resource is used to create, update, and get properties of bidding strategies within a single account . As mentioned in the previous section, when that account is a manager, then mutating and reading from a BiddingStrategy resource manages cross-account bidding strategies.

Thus, when you are making API calls with a manager account, you can list and read its list of owned cross-account bidding strategies by querying the BiddingStrategy resource:

Java

 private 
  
 void 
  
 listManagerOwnedBiddingStrategies 
 ( 
  
 GoogleAdsClient 
  
 googleAdsClient 
 , 
  
 long 
  
 managerCustomerId 
 ) 
  
 throws 
  
 GoogleAdsException 
  
 { 
  
 try 
  
 ( 
 GoogleAdsServiceClient 
  
 googleAdsServiceClient 
  
 = 
  
 googleAdsClient 
 . 
 getLatestVersion 
 (). 
 createGoogleAdsServiceClient 
 ()) 
  
 { 
  
 String 
  
 query 
  
 = 
  
 "SELECT bidding_strategy.id, " 
  
 + 
  
 "bidding_strategy.name, " 
  
 + 
  
 "bidding_strategy.type, " 
  
 + 
  
 "bidding_strategy.currency_code " 
  
 + 
  
 "FROM bidding_strategy" 
 ; 
  
 // Constructs the SearchGoogleAdsStreamRequest. 
  
 SearchGoogleAdsStreamRequest 
  
 request 
  
 = 
  
 SearchGoogleAdsStreamRequest 
 . 
 newBuilder 
 () 
  
 . 
 setCustomerId 
 ( 
 Long 
 . 
 toString 
 ( 
 managerCustomerId 
 )) 
  
 . 
 setQuery 
 ( 
 query 
 ) 
  
 . 
 build 
 (); 
  
 // Creates and issues a search Google Ads stream request that will retrieve all bidding 
  
 // strategies. 
  
 ServerStream<SearchGoogleAdsStreamResponse> 
  
 stream 
  
 = 
  
 googleAdsServiceClient 
 . 
 searchStreamCallable 
 (). 
 call 
 ( 
 request 
 ); 
  
 // Iterates through and prints all of the results in the stream response. 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
  
 "Cross-account bid strategies in manager account %d: %n" 
 , 
  
 managerCustomerId 
 ); 
  
 for 
  
 ( 
 SearchGoogleAdsStreamResponse 
  
 response 
  
 : 
  
 stream 
 ) 
  
 { 
  
 for 
  
 ( 
 GoogleAdsRow 
  
 googleAdsRow 
  
 : 
  
 response 
 . 
 getResultsList 
 ()) 
  
 { 
  
 BiddingStrategy 
  
 bs 
  
 = 
  
 googleAdsRow 
 . 
 getBiddingStrategy 
 (); 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "  ID: %d%n" 
 , 
  
 bs 
 . 
 getId 
 ()); 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "  Name: %s%n" 
 , 
  
 bs 
 . 
 getName 
 ()); 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "  Strategy type: %s%n" 
 , 
  
 bs 
 . 
 getType 
 ()); 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "  Currency: %s%n" 
 , 
  
 bs 
 . 
 getCurrencyCode 
 ()); 
  
 System 
 . 
 out 
 . 
 println 
 (); 
  
 } 
  
 } 
  
 } 
 } 
  
  

C#

 /// <summary> 
 /// Lists all cross-account bidding strategies in a specified manager account. 
 /// </summary> 
 /// <param name="client">The Google Ads client.</param> 
 /// <param name="managerCustomerId">The manager customer ID.</param> 
 private 
  
 void 
  
 ListManagerOwnedBiddingStrategies 
 ( 
 GoogleAdsClient 
  
 client 
 , 
  
 long 
  
 managerCustomerId 
 ) 
 { 
  
 GoogleAdsServiceClient 
  
 googleAdsServiceClient 
  
 = 
  
 client 
 . 
 GetService 
 ( 
 Services 
 . 
 V21 
 . 
 GoogleAdsService 
 ); 
  
 // Create a GAQL query that will retrieve all cross-account bidding strategies. 
  
 string 
  
 query 
  
 = 
  
 @" 
 SELECT 
 bidding_strategy.id, 
 bidding_strategy.name, 
 bidding_strategy.type, 
 bidding_strategy.currency_code 
 FROM bidding_strategy" 
 ; 
  
 // Issue a streaming search request, then iterate through and print the results. 
  
 googleAdsServiceClient 
 . 
 SearchStream 
 ( 
 managerCustomerId 
 . 
 ToString 
 (), 
  
 query 
 , 
  
 delegate 
 ( 
 SearchGoogleAdsStreamResponse 
  
 resp 
 ) 
  
 { 
  
 Console 
 . 
 WriteLine 
 ( 
 "Cross-account bid strategies in manager account " 
  
 + 
  
 $"{managerCustomerId}:" 
 ); 
  
 foreach 
  
 ( 
 GoogleAdsRow 
  
 googleAdsRow 
  
 in 
  
 resp 
 . 
 Results 
 ) 
  
 { 
  
 BiddingStrategy 
  
 biddingStrategy 
  
 = 
  
 googleAdsRow 
 . 
 BiddingStrategy 
 ; 
  
 Console 
 . 
 WriteLine 
 ( 
 $"\tID: {biddingStrategy.Id}\n" 
  
 + 
  
 $"\tName: {biddingStrategy.Name}\n" 
  
 + 
  
 "\tStrategy type: " 
  
 + 
  
 $"{Enum.GetName(typeof(BiddingStrategyType), biddingStrategy.Type)}\n" 
  
 + 
  
 $"\tCurrency: {biddingStrategy.CurrencyCode}\n\n" 
 ); 
  
 } 
  
 } 
  
 ); 
 } 
  
  

PHP

 private static function listManagerOwnedBiddingStrategies( 
 GoogleAdsClient $googleAdsClient, 
 int $managerCustomerId 
 ) { 
 $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient(); 
 // Creates a query that retrieves all bidding strategies. 
 $query = 'SELECT bidding_strategy.id, bidding_strategy.name, ' 
 . 'bidding_strategy.type, bidding_strategy.currency_code ' 
 . 'FROM bidding_strategy'; 
 // Issues a search stream request. 
 /** @var GoogleAdsServerStreamDecorator $stream */ 
 $stream = $googleAdsServiceClient->searchStream( 
 SearchGoogleAdsStreamRequest::build($managerCustomerId, $query) 
 ); 
 // Iterates over all rows in all messages and prints the requested field values for 
 // the bidding strategy in each row. 
 printf( 
 "Cross-account bid strategies in manager account ID %d:%s", 
 $managerCustomerId, 
 PHP_EOL 
 ); 
 foreach ($stream->iterateAllElements() as $googleAdsRow) { 
 /** @var GoogleAdsRow $googleAdsRow */ 
 printf( 
 '  ID: %1$d%2$s  Name: "%3$s"%2$s  Strategy type: "%4$s"%2$s' 
 . '  Currency: "%5$s"%2$s%2$s', 
 $googleAdsRow->getBiddingStrategy()->getId(), 
 PHP_EOL, 
 $googleAdsRow->getBiddingStrategy()->getName(), 
 BiddingStrategyType::name($googleAdsRow->getBiddingStrategy()->getType()), 
 $googleAdsRow->getBiddingStrategy()->getCurrencyCode() 
 ); 
 } 
 }  
 

Python

 def 
  
 list_manager_owned_bidding_strategies 
 ( 
 client 
 : 
 GoogleAdsClient 
 , 
 manager_customer_id 
 : 
 str 
 ) 
 - 
> None 
 : 
  
 """List all cross-account bidding strategies in the manager account. 
 Args: 
 client: An initialized GoogleAdsClient instance. 
 manager_customer_id: A manager customer ID. 
 """ 
 googleads_service 
 : 
 GoogleAdsServiceClient 
 = 
 client 
 . 
 get_service 
 ( 
 "GoogleAdsService" 
 ) 
 query 
 = 
 """ 
 SELECT 
 bidding_strategy.id, 
 bidding_strategy.name, 
 bidding_strategy.type, 
 bidding_strategy.currency_code 
 FROM bidding_strategy""" 
 # Creates and issues a search Google Ads stream request that will retrieve 
 # all bidding strategies. 
 stream 
 : 
 Iterator 
 [ 
 SearchGoogleAdsStreamResponse 
 ] 
 = 
 ( 
 googleads_service 
 . 
 search_stream 
 ( 
 customer_id 
 = 
 manager_customer_id 
 , 
 query 
 = 
 query 
 ) 
 ) 
 # Iterates through and prints all of the results in the stream response. 
 print 
 ( 
 "Cross-account bid strategies in manager account: " 
 f 
 " 
 { 
 manager_customer_id 
 } 
 " 
 ) 
 response 
 : 
 SearchGoogleAdsStreamResponse 
 for 
 response 
 in 
 stream 
 : 
 row 
 : 
 GoogleAdsRow 
 for 
 row 
 in 
 response 
 . 
 results 
 : 
 bs 
 : 
 BiddingStrategy 
 = 
 row 
 . 
 bidding_strategy 
 print 
 ( 
 f 
 " 
 \t 
 ID: 
 { 
 bs 
 . 
 id 
 } 
 \n 
 " 
 f 
 " 
 \t 
 Name: 
 { 
 bs 
 . 
 name 
 } 
 \n 
 " 
 f 
 " 
 \t 
 Strategy type: 
 { 
 bs 
 . 
 type_ 
 . 
 name 
 } 
 \n 
 " 
 f 
 " 
 \t 
 Currency: 
 { 
 bs 
 . 
 currency_code 
 } 
 \n\n 
 " 
 ) 
  

Ruby

 def 
  
 list_manager_owned_bidding_strategies 
 ( 
 client 
 , 
  
 manager_customer_id 
 ) 
  
 query 
  
 = 
  
<< ~ 
 QUERY 
  
 SELECT 
  
 bidding_strategy 
 . 
 id 
 , 
  
 bidding_strategy 
 . 
 name 
 , 
  
 bidding_strategy 
 . 
 type 
 , 
  
 bidding_strategy 
 . 
 currency_code 
  
 FROM 
  
 bidding_strategy 
  
 QUERY 
  
 responses 
  
 = 
  
 client 
 . 
 service 
 . 
 google_ads 
 . 
 search_stream 
 ( 
  
 customer_id 
 : 
  
 manager_customer_id 
 , 
  
 query 
 : 
  
 query 
 , 
  
 ) 
  
 puts 
  
 "Cross-account bid strategies in manager account 
 #{ 
 manager_customer_id 
 } 
 :" 
  
 responses 
 . 
 each 
  
 do 
  
 | 
 response 
 | 
  
 response 
 . 
 results 
 . 
 each 
  
 do 
  
 | 
 row 
 | 
  
 b 
  
 = 
  
 row 
 . 
 bidding_strategy 
  
 puts 
  
 "ID: 
 #{ 
 b 
 . 
 id 
 } 
 " 
  
 puts 
  
 "Name: 
 #{ 
 b 
 . 
 name 
 } 
 " 
  
 puts 
  
 "Strategy type: 
 #{ 
 b 
 . 
 type 
 } 
 " 
  
 puts 
  
 "Currency: 
 #{ 
 b 
 . 
 currency_code 
 } 
 " 
  
 puts 
  
 end 
  
 end 
 end  
 
 . 
 rb 
  

Perl

 # Lists all cross-account bidding strategies in a specified manager account. 
 sub 
  
 _list_manager_owned_bidding_strategies 
  
 { 
  
 my 
  
 ( 
 $api_client 
 , 
  
 $manager_customer_id 
 ) 
  
 = 
  
 @_ 
 ; 
  
 # Create a GAQL query that will retrieve all cross-account bidding 
  
 # strategies. 
  
 my 
  
 $query 
  
 = 
  
 "SELECT 
 bidding_strategy.id, 
 bidding_strategy.name, 
 bidding_strategy.type, 
 bidding_strategy.currency_code 
 FROM bidding_strategy" 
 ; 
  
 # Issue a streaming search request, then iterate through and print the 
  
 # results. 
  
 my 
  
 $search_stream_handler 
  
 = 
  
 Google::Ads::GoogleAds::Utils:: 
 SearchStreamHandler 
 - 
> new 
 ({ 
  
 service 
  
 = 
>  
 $api_client 
 - 
> GoogleAdsService 
 (), 
  
 request 
  
 = 
>  
 Google::Ads::GoogleAds::V21::Services::GoogleAdsService:: 
 SearchGoogleAdsStreamRequest 
  
 - 
> new 
 ({ 
  
 customerId 
  
 = 
>  
 $manager_customer_id 
 , 
  
 query 
  
 = 
>  
 $query 
  
 })}); 
  
 printf 
  
 "Cross-account bid strategies in manager account $manager_customer_id:\n" 
 ; 
  
 $search_stream_handler 
 - 
> process_contents 
 ( 
  
 sub 
  
 { 
  
 my 
  
 $google_ads_row 
  
 = 
  
 shift 
 ; 
  
 my 
  
 $bidding_strategy 
  
 = 
  
 $google_ads_row 
 - 
> { 
 biddingStrategy 
 }; 
  
 printf 
  
 "\tID: $bidding_strategy->{id}\n" 
  
 . 
  
 "\tName: $bidding_strategy->{name}\n" 
  
 . 
  
 "\tStrategy type: $bidding_strategy->{type}\n" 
  
 . 
  
 "\tCurrency: $bidding_strategy->{currencyCode}\n\n" 
 ; 
  
 }); 
 } 
  
  

View accessible bidding strategies

When working with client accounts that use cross-account bidding strategies, the AccessibleBiddingStrategy resource is used to provide a read-only view of all bidding strategies accessible to the current customer. This includes both portfolio strategies owned by the customer and cross-account bidding strategies shared with the customer.

Get all accessible bidding strategies

To retrieve all bidding strategies accessible by the current customer, query the accessible_bidding_strategy resource directly. The results will by default include both portfolio strategies in the current account and cross-account bidding strategies shared by a manager.

Java

 private 
  
 void 
  
 listCustomerAccessibleBiddingStrategies 
 ( 
  
 GoogleAdsClient 
  
 googleAdsClient 
 , 
  
 long 
  
 clientCustomerId 
 ) 
  
 throws 
  
 GoogleAdsException 
  
 { 
  
 try 
  
 ( 
 GoogleAdsServiceClient 
  
 googleAdsServiceClient 
  
 = 
  
 googleAdsClient 
 . 
 getLatestVersion 
 (). 
 createGoogleAdsServiceClient 
 ()) 
  
 { 
  
 String 
  
 query 
  
 = 
  
 "SELECT accessible_bidding_strategy.id, " 
  
 + 
  
 "accessible_bidding_strategy.name, " 
  
 + 
  
 "accessible_bidding_strategy.type, " 
  
 + 
  
 "accessible_bidding_strategy.owner_customer_id, " 
  
 + 
  
 "accessible_bidding_strategy.owner_descriptive_name " 
  
 + 
  
 "FROM accessible_bidding_strategy " 
  
 // Uncomment the following WHERE clause to filter results to *only* cross-account bidding 
  
 // strategies shared with the current customer by a manager (and not also include the 
  
 // current customer's portfolio bidding strategies). 
  
 // + "WHERE accessible_bidding_strategy.owner_customer_id != " + clientCustomerId; 
  
 ; 
  
 // Constructs the SearchGoogleAdsStreamRequest. 
  
 SearchGoogleAdsStreamRequest 
  
 request 
  
 = 
  
 SearchGoogleAdsStreamRequest 
 . 
 newBuilder 
 () 
  
 . 
 setCustomerId 
 ( 
 Long 
 . 
 toString 
 ( 
 clientCustomerId 
 )) 
  
 . 
 setQuery 
 ( 
 query 
 ) 
  
 . 
 build 
 (); 
  
 // Creates and issues a search Google Ads stream request that will retrieve all accessible 
  
 // bidding strategies. 
  
 ServerStream<SearchGoogleAdsStreamResponse> 
  
 stream 
  
 = 
  
 googleAdsServiceClient 
 . 
 searchStreamCallable 
 (). 
 call 
 ( 
 request 
 ); 
  
 // Iterates through and prints all of the results in the stream response. 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "All bid strategies accessible by account %d: %n" 
 , 
  
 clientCustomerId 
 ); 
  
 for 
  
 ( 
 SearchGoogleAdsStreamResponse 
  
 response 
  
 : 
  
 stream 
 ) 
  
 { 
  
 for 
  
 ( 
 GoogleAdsRow 
  
 googleAdsRow 
  
 : 
  
 response 
 . 
 getResultsList 
 ()) 
  
 { 
  
 AccessibleBiddingStrategy 
  
 bs 
  
 = 
  
 googleAdsRow 
 . 
 getAccessibleBiddingStrategy 
 (); 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "  ID: %d%n" 
 , 
  
 bs 
 . 
 getId 
 ()); 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "  Name: %s%n" 
 , 
  
 bs 
 . 
 getName 
 ()); 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "  Strategy type: %s%n" 
 , 
  
 bs 
 . 
 getType 
 ()); 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "  Owner customer ID: %d%n" 
 , 
  
 bs 
 . 
 getOwnerCustomerId 
 ()); 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "  Owner description: %s%n" 
 , 
  
 bs 
 . 
 getOwnerDescriptiveName 
 ()); 
  
 System 
 . 
 out 
 . 
 println 
 (); 
  
 } 
  
 } 
  
 } 
 } 
  
  

C#

 /// <summary> 
 /// Lists all bidding strategies available to specified client customer account. This 
 /// includes both portfolio bidding strategies owned by the client customer account and 
 /// cross-account bidding strategies shared by any of its managers. 
 /// </summary> 
 /// <param name="client">The Google Ads client.</param> 
 /// <param name="customerId">The Google Ads client customer ID for which the call is 
 /// made.</param> 
 private 
  
 void 
  
 ListCustomerAccessibleBiddingStrategies 
 ( 
 GoogleAdsClient 
  
 client 
 , 
  
 long 
  
 customerId 
 ) 
 { 
  
 GoogleAdsServiceClient 
  
 googleAdsServiceClient 
  
 = 
  
 client 
 . 
 GetService 
 ( 
 Services 
 . 
 V21 
 . 
 GoogleAdsService 
 ); 
  
 // Create a GAQL query that will retrieve all accessible bidding strategies. 
  
 string 
  
 query 
  
 = 
  
 @" 
 SELECT 
 accessible_bidding_strategy.resource_name, 
 accessible_bidding_strategy.id, 
 accessible_bidding_strategy.name, 
 accessible_bidding_strategy.type, 
 accessible_bidding_strategy.owner_customer_id, 
 accessible_bidding_strategy.owner_descriptive_name 
 FROM accessible_bidding_strategy" 
 ; 
  
 // Uncomment the following WHERE clause addition to the query to filter results to 
  
 // *only* cross-account bidding strategies shared with the current customer by a manager 
  
 // (and not also include the current customer's portfolio bidding strategies). 
  
 // query += $" WHERE accessible_bidding_strategy.owner_customer_id != {customerId}"; 
  
 // Issue a streaming search request, then iterate through and print the results. 
  
 googleAdsServiceClient 
 . 
 SearchStream 
 ( 
 customerId 
 . 
 ToString 
 (), 
  
 query 
 , 
  
 delegate 
 ( 
 SearchGoogleAdsStreamResponse 
  
 resp 
 ) 
  
 { 
  
 Console 
 . 
 WriteLine 
 ( 
 $"All bid strategies accessible by account {customerId}:" 
 ); 
  
 foreach 
  
 ( 
 GoogleAdsRow 
  
 googleAdsRow 
  
 in 
  
 resp 
 . 
 Results 
 ) 
  
 { 
  
 AccessibleBiddingStrategy 
  
 biddingStrategy 
  
 = 
  
 googleAdsRow 
 . 
 AccessibleBiddingStrategy 
 ; 
  
 Console 
 . 
 WriteLine 
 ( 
 $"\tID: {biddingStrategy.Id}\n" 
  
 + 
  
 $"\tName: {biddingStrategy.Name}\n" 
  
 + 
  
 $"\tStrategy type: {biddingStrategy.Type.ToString()}\n" 
  
 + 
  
 $"\tOwner customer ID: {biddingStrategy.OwnerCustomerId}\n" 
  
 + 
  
 $"\tOwner description: {biddingStrategy.OwnerDescriptiveName}\n\n" 
 ); 
  
 } 
  
 } 
  
 ); 
 } 
  
  

PHP

 private static function listCustomerAccessibleBiddingStrategies( 
 GoogleAdsClient $googleAdsClient, 
 int $clientCustomerId 
 ) { 
 $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient(); 
 // Creates a query that retrieves all bidding strategies. 
 $query = 'SELECT accessible_bidding_strategy.id, ' 
 . 'accessible_bidding_strategy.name, ' 
 . 'accessible_bidding_strategy.type, ' 
 . 'accessible_bidding_strategy.owner_customer_id, ' 
 . 'accessible_bidding_strategy.owner_descriptive_name ' 
 . 'FROM accessible_bidding_strategy ' 
 // Uncomment the following WHERE clause to filter results to *only* cross-account 
 // bidding strategies shared with the current customer by a manager (and not also 
 // include the current customer's portfolio bidding strategies). 
 // . 'WHERE accessible_bidding_strategy.owner_customer_id != ' . $clientCustomerId 
 ; 
 // Issues a search stream request. 
 /** @var GoogleAdsServerStreamDecorator $stream */ 
 $stream = $googleAdsServiceClient->searchStream( 
 SearchGoogleAdsStreamRequest::build($clientCustomerId, $query) 
 ); 
 // Iterates over all rows in all messages and prints the requested field values for 
 // each accessible bidding strategy. 
 printf( 
 "All bid strategies accessible by the customer ID %d:%s", 
 $clientCustomerId, 
 PHP_EOL 
 ); 
 foreach ($stream->iterateAllElements() as $googleAdsRow) { 
 /** @var GoogleAdsRow $googleAdsRow */ 
 printf( 
 '  ID: %1$d%2$s  Name: "%3$s"%2$s  Strategy type: "%4$s"%2$s' 
 . '  Owner customer ID: %5$d%2$s  Owner customer description: "%6$s"%2$s%2$s', 
 $googleAdsRow->getAccessibleBiddingStrategy()->getId(), 
 PHP_EOL, 
 $googleAdsRow->getAccessibleBiddingStrategy()->getName(), 
 BiddingStrategyType::name($googleAdsRow->getAccessibleBiddingStrategy()->getType()), 
 $googleAdsRow->getAccessibleBiddingStrategy()->getOwnerCustomerId(), 
 $googleAdsRow->getAccessibleBiddingStrategy()->getOwnerDescriptiveName() 
 ); 
 } 
 }  
 

Python

 def 
  
 list_customer_accessible_bidding_strategies 
 ( 
 client 
 : 
 GoogleAdsClient 
 , 
 customer_id 
 : 
 str 
 ) 
 - 
> None 
 : 
  
 """Lists all bidding strategies available to the client account. 
 This includes both portfolio bidding strategies owned by account and 
 cross-account bidding strategies shared by any of its managers. 
 Args: 
 client: An initialized GoogleAdsClient instance. 
 customer_id: A client customer ID. 
 """ 
 googleads_service 
 : 
 GoogleAdsServiceClient 
 = 
 client 
 . 
 get_service 
 ( 
 "GoogleAdsService" 
 ) 
 query 
 = 
 """ 
 SELECT 
 accessible_bidding_strategy.id, 
 accessible_bidding_strategy.name, 
 accessible_bidding_strategy.type, 
 accessible_bidding_strategy.owner_customer_id, 
 accessible_bidding_strategy.owner_descriptive_name 
 FROM accessible_bidding_strategy""" 
 # Uncomment the following WHERE clause to filter results to *only* 
 # cross-account bidding strategies shared with the current customer by a 
 # manager (and not also include the current customer's portfolio 
 # bidding strategies). 
 # 
 # query += f"WHERE accessible_bidding_strategy.owner_customer_id != {customer_id}" 
 # Creates and issues a search Google Ads stream request that will retrieve 
 # all bidding strategies. 
 stream 
 : 
 Iterator 
 [ 
 SearchGoogleAdsStreamResponse 
 ] 
 = 
 ( 
 googleads_service 
 . 
 search_stream 
 ( 
 customer_id 
 = 
 customer_id 
 , 
 query 
 = 
 query 
 ) 
 ) 
 # Iterates through and prints all of the results in the stream response. 
 print 
 ( 
 f 
 "All bid strategies accessible by account ' 
 { 
 customer_id 
 } 
 ' 
 \n 
 " 
 ) 
 response 
 : 
 SearchGoogleAdsStreamResponse 
 for 
 response 
 in 
 stream 
 : 
 row 
 : 
 GoogleAdsRow 
 for 
 row 
 in 
 response 
 . 
 results 
 : 
 bs 
 : 
 AccessibleBiddingStrategy 
 = 
 row 
 . 
 accessible_bidding_strategy 
 print 
 ( 
 f 
 " 
 \t 
 ID: 
 { 
 bs 
 . 
 id 
 } 
 \n 
 " 
 f 
 " 
 \t 
 Name: 
 { 
 bs 
 . 
 name 
 } 
 \n 
 " 
 f 
 " 
 \t 
 Strategy type: 
 { 
 bs 
 . 
 type_ 
 . 
 name 
 } 
 \n 
 " 
 f 
 " 
 \t 
 Owner customer ID: 
 { 
 bs 
 . 
 owner_customer_id 
 } 
 \n 
 " 
 f 
 " 
 \t 
 Owner description: 
 { 
 bs 
 . 
 owner_descriptive_name 
 } 
 \n\n 
 " 
 ) 
  

Ruby

 def 
  
 list_customer_accessible_bidding_strategies 
 ( 
 client 
 , 
  
 customer_id 
 ) 
  
 query 
  
 = 
  
<< ~ 
 QUERY 
  
 SELECT 
  
 accessible_bidding_strategy 
 . 
 id 
 , 
  
 accessible_bidding_strategy 
 . 
 name 
 , 
  
 accessible_bidding_strategy 
 . 
 type 
 , 
  
 accessible_bidding_strategy 
 . 
 owner_customer_id 
 , 
  
 accessible_bidding_strategy 
 . 
 owner_descriptive_name 
  
 FROM 
  
 accessible_bidding_strategy 
  
 QUERY 
  
 # Add the following WHERE clause to filter results to *only* 
  
 # cross-account bidding strategies shared with the current customer by a 
  
 # manager (and not also include the current customer's portfolio bidding 
  
 # strategies). 
  
 # query += <<~QUERY 
  
 #  WHERE accessible_bidding_strategy.owner_customer_id != #{customer_id} 
  
 # QUERY 
  
 responses 
  
 = 
  
 client 
 . 
 service 
 . 
 google_ads 
 . 
 search_stream 
 ( 
  
 customer_id 
 : 
  
 customer_id 
 , 
  
 query 
 : 
  
 query 
 , 
  
 ) 
  
 puts 
  
 "All bid strategies accessible by account 
 #{ 
 customer_id 
 } 
 :" 
  
 responses 
 . 
 each 
  
 do 
  
 | 
 response 
 | 
  
 response 
 . 
 results 
 . 
 each 
  
 do 
  
 | 
 row 
 | 
  
 b 
  
 = 
  
 row 
 . 
 accessible_bidding_strategy 
  
 puts 
  
 "ID: 
 #{ 
 b 
 . 
 id 
 } 
 " 
  
 puts 
  
 "Name: 
 #{ 
 b 
 . 
 name 
 } 
 " 
  
 puts 
  
 "Strategy type: 
 #{ 
 b 
 . 
 type 
 } 
 " 
  
 puts 
  
 "Owner customer ID: 
 #{ 
 b 
 . 
 owner_customer_id 
 } 
 " 
  
 puts 
  
 "Owner description: 
 #{ 
 b 
 . 
 owner_descriptive_name 
 } 
 " 
  
 puts 
  
 end 
  
 end 
 end  
 
 . 
 rb 
  

Perl

 # Lists all bidding strategies available to specified client customer account. 
 # This includes both portfolio bidding strategies owned by the client customer 
 # account and cross-account bidding strategies shared by any of its managers. 
 sub 
  
 _list_customer_accessible_bidding_strategies 
  
 { 
  
 my 
  
 ( 
 $api_client 
 , 
  
 $customer_id 
 ) 
  
 = 
  
 @_ 
 ; 
  
 # Create a GAQL query that will retrieve all accessible bidding strategies. 
  
 my 
  
 $query 
  
 = 
  
 "SELECT 
 accessible_bidding_strategy.resource_name, 
 accessible_bidding_strategy.id, 
 accessible_bidding_strategy.name, 
 accessible_bidding_strategy.type, 
 accessible_bidding_strategy.owner_customer_id, 
 accessible_bidding_strategy.owner_descriptive_name 
 FROM accessible_bidding_strategy" 
 ; 
  
 # Uncomment the following WHERE clause addition to the query to filter results 
  
 # to *only* cross-account bidding strategies shared with the current customer 
  
 # by a manager (and not also include the current customer's portfolio bidding 
  
 # strategies). 
  
 # $query .= 
  
 #   " WHERE accessible_bidding_strategy.owner_customer_id != $customer_id"; 
  
 # Issue a streaming search request, then iterate through and print the 
  
 # results. 
  
 my 
  
 $search_stream_handler 
  
 = 
  
 Google::Ads::GoogleAds::Utils:: 
 SearchStreamHandler 
 - 
> new 
 ({ 
  
 service 
  
 = 
>  
 $api_client 
 - 
> GoogleAdsService 
 (), 
  
 request 
  
 = 
>  
 Google::Ads::GoogleAds::V21::Services::GoogleAdsService:: 
 SearchGoogleAdsStreamRequest 
  
 - 
> new 
 ({ 
  
 customerId 
  
 = 
>  
 $customer_id 
 , 
  
 query 
  
 = 
>  
 $query 
  
 })}); 
  
 printf 
  
 "All bid strategies accessible by account $customer_id:\n" 
 ; 
  
 $search_stream_handler 
 - 
> process_contents 
 ( 
  
 sub 
  
 { 
  
 my 
  
 $google_ads_row 
  
 = 
  
 shift 
 ; 
  
 my 
  
 $bidding_strategy 
  
 = 
  
 $google_ads_row 
 - 
> { 
 accessibleBiddingStrategy 
 }; 
  
 printf 
  
 "\tID: $bidding_strategy->{id}\n" 
  
 . 
  
 "\tName: $bidding_strategy->{name}\n" 
  
 . 
  
 "\tStrategy type: $bidding_strategy->{type}\n" 
  
 . 
  
 "\tOwner customer ID: $bidding_strategy->{ownerCustomerId}\n" 
  
 . 
  
 "\tOwner description: $bidding_strategy->{ownerDescriptiveName}\n\n" 
 ; 
  
 }); 
 } 
  
  

Get information about specific campaigns

You can also fetch fields of bidding_strategy and accessible_bidding_strategy when you query for campaigns. By using campaign in your query's FROM clause, the matching campaigns will implicitly join any associated bidding_strategy and accessible_bidding_strategy resources.

For example, the following query will fetch all active campaigns and fields of their associated bidding_strategy and accessible_bidding_strategy resources.

GAQL

 SELECT 
  
 campaign 
 . 
 id 
 , 
  
 campaign 
 . 
 name 
 , 
  
 campaign 
 . 
 bidding_strategy 
 , 
  
 campaign 
 . 
 bidding_strategy_type 
 , 
  
 accessible_bidding_strategy 
 . 
 id 
 , 
  
 accessible_bidding_strategy 
 . 
 name 
 , 
  
 accessible_bidding_strategy 
 . 
 type 
 , 
  
 accessible_bidding_strategy 
 . 
 owner_customer_id 
 , 
  
 accessible_bidding_strategy 
 . 
 owner_descriptive_name 
 , 
  
 bidding_strategy 
 . 
 name 
 , 
  
 bidding_strategy 
 . 
 type 
 FROM 
  
 campaign 
 WHERE 
  
 campaign 
 . 
 status 
  
 != 
  
 REMOVED 

Attach to campaigns

Similar to standard portfolio bidding strategies , you attach a cross-account bidding strategy to a campaign by setting its bidding_strategy to the resource name of a cross-account bidding strategy. Only managers that own a cross-account bidding strategy (or managers of those managers) can attach them to campaigns. So API calls that attach cross-account bidding strategies to a campaign must use a login-customer-id of a manager that has the appropriate access to the bidding strategy.

Java

 private 
  
 void 
  
 attachCrossAccountBiddingStrategyToCampaign 
 ( 
  
 GoogleAdsClient 
  
 googleAdsClient 
 , 
  
 long 
  
 clientCustomerId 
 , 
  
 long 
  
 campaignId 
 , 
  
 String 
  
 biddingStrategyResourceName 
 ) 
  
 throws 
  
 GoogleAdsException 
  
 { 
  
 try 
  
 ( 
 CampaignServiceClient 
  
 campaignServiceClient 
  
 = 
  
 googleAdsClient 
 . 
 getLatestVersion 
 (). 
 createCampaignServiceClient 
 ()) 
  
 { 
  
 Campaign 
  
 campaign 
  
 = 
  
 Campaign 
 . 
 newBuilder 
 () 
  
 . 
 setResourceName 
 ( 
 ResourceNames 
 . 
 campaign 
 ( 
 clientCustomerId 
 , 
  
 campaignId 
 )) 
  
 . 
 setBiddingStrategy 
 ( 
 biddingStrategyResourceName 
 ) 
  
 // Declares whether this campaign serves political ads targeting the EU. 
  
 . 
 setContainsEuPoliticalAdvertising 
 ( 
 DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING 
 ) 
  
 . 
 build 
 (); 
  
 CampaignOperation 
  
 operation 
  
 = 
  
 CampaignOperation 
 . 
 newBuilder 
 () 
  
 . 
 setUpdate 
 ( 
 campaign 
 ) 
  
 . 
 setUpdateMask 
 ( 
 FieldMasks 
 . 
 allSetFieldsOf 
 ( 
 campaign 
 )) 
  
 . 
 build 
 (); 
  
 // Sends the operation in a mutate request. 
  
 MutateCampaignsResponse 
  
 response 
  
 = 
  
 campaignServiceClient 
 . 
 mutateCampaigns 
 ( 
  
 Long 
 . 
 toString 
 ( 
 clientCustomerId 
 ), 
  
 ImmutableList 
 . 
 of 
 ( 
 operation 
 )); 
  
 MutateCampaignResult 
  
 mutateCampaignResult 
  
 = 
  
 response 
 . 
 getResults 
 ( 
 0 
 ); 
  
 // Prints the resource name of the updated campaign. 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
  
 "Updated campaign with resource name: '%s'.%n" 
 , 
  
 mutateCampaignResult 
 . 
 getResourceName 
 ()); 
  
 } 
 } 
  
  

C#

 /// <summary> 
 /// Attaches a specified cross-account bidding strategy to a campaign owned by a specified 
 /// client customer account. 
 /// </summary> 
 /// <param name="client">The Google Ads client.</param> 
 /// <param name="customerId">The Google Ads client customer ID for which the call is 
 /// made.</param> 
 /// <param name="campaignId">The ID of the campaign owned by the customer ID to which the 
 /// cross-account bidding strategy will be attached.</param> 
 /// <param name="biddingStrategyResourceName">A cross-account bidding strategy resource 
 /// name.</param> 
 private 
  
 void 
  
 AttachCrossAccountBiddingStrategyToCampaign 
 ( 
 GoogleAdsClient 
  
 client 
 , 
  
 long 
  
 customerId 
 , 
  
 long 
  
 campaignId 
 , 
  
 string 
  
 biddingStrategyResourceName 
 ) 
 { 
  
 CampaignServiceClient 
  
 campaignServiceClient 
  
 = 
  
 client 
 . 
 GetService 
 ( 
 Services 
 . 
 V21 
 . 
 CampaignService 
 ); 
  
 Campaign 
  
 campaign 
  
 = 
  
 new 
  
 Campaign 
  
 { 
  
 ResourceName 
  
 = 
  
 ResourceNames 
 . 
 Campaign 
 ( 
 customerId 
 , 
  
 campaignId 
 ), 
  
 BiddingStrategy 
  
 = 
  
 biddingStrategyResourceName 
  
 }; 
  
 // Mutate the campaign and print the resource name of the updated campaign. 
  
 MutateCampaignsResponse 
  
 mutateCampaignsResponse 
  
 = 
  
 campaignServiceClient 
 . 
 MutateCampaigns 
 ( 
 customerId 
 . 
 ToString 
 (), 
  
 new 
 [] 
  
 { 
  
 new 
  
 CampaignOperation 
  
 { 
  
 Update 
  
 = 
  
 campaign 
 , 
  
 UpdateMask 
  
 = 
  
 FieldMasks 
 . 
 AllSetFieldsOf 
 ( 
 campaign 
 ) 
  
 } 
  
 }); 
  
 Console 
 . 
 WriteLine 
 ( 
 "Updated campaign with resource name " 
  
 + 
  
 $"'{mutateCampaignsResponse.Results.First().ResourceName}'." 
 ); 
 } 
  
  

PHP

 private static function attachCrossAccountBiddingStrategyToCampaign( 
 GoogleAdsClient $googleAdsClient, 
 int $clientCustomerId, 
 int $campaignId, 
 string $biddingStrategyResourceName 
 ) { 
 // Creates a campaign using the specified campaign ID and the bidding strategy ID. 
 // Note that a cross-account bidding strategy's resource name should use the 
 // client's customer ID when attaching it to a campaign, not that of the manager that owns 
 // the strategy. 
 $campaign = new Campaign([ 
 'resource_name' => ResourceNames::forCampaign($clientCustomerId, $campaignId), 
 'bidding_strategy' => $biddingStrategyResourceName 
 ]); 
 // Constructs an operation that will update the campaign with the specified resource name, 
 // using the FieldMasks utility to derive the update mask. This mask tells the Google Ads 
 // API which attributes of the campaign you want to change. 
 $campaignOperation = new CampaignOperation(); 
 $campaignOperation->setUpdate($campaign); 
 $campaignOperation->setUpdateMask(FieldMasks::allSetFieldsOf($campaign)); 
 // Issues a mutate request to update the campaign. 
 $campaignServiceClient = $googleAdsClient->getCampaignServiceClient(); 
 $response = $campaignServiceClient->mutateCampaigns( 
 MutateCampaignsRequest::build($clientCustomerId, [$campaignOperation]) 
 ); 
 // Prints information about the updated campaign. 
 printf( 
 "Updated campaign with resource name: '%s'.%s", 
 $response->getResults()[0]->getResourceName(), 
 PHP_EOL 
 ); 
 }  
 

Python

 def 
  
 attach_cross_account_bidding_strategy_to_campaign 
 ( 
 client 
 : 
 GoogleAdsClient 
 , 
 customer_id 
 : 
 str 
 , 
 campaign_id 
 : 
 str 
 , 
 bidding_strategy_resource_name 
 : 
 str 
 , 
 ) 
 - 
> None 
 : 
  
 """Attaches the cross-account bidding strategy to the given campaign. 
 Args: 
 client: An initialized GoogleAdsClient instance. 
 customer_id: A client customer ID. 
 campaign_id: The ID of an existing campaign in the client customer's 
 account. 
 bidding_strategy_resource_name: The ID of a bidding strategy 
 """ 
 campaign_service 
 : 
 CampaignServiceClient 
 = 
 client 
 . 
 get_service 
 ( 
 "CampaignService" 
 ) 
 campaign_operation 
 : 
 CampaignOperation 
 = 
 client 
 . 
 get_type 
 ( 
 "CampaignOperation" 
 ) 
 campaign 
 : 
 Campaign 
 = 
 campaign_operation 
 . 
 update 
 campaign 
 . 
 resource_name 
 = 
 campaign_service 
 . 
 campaign_path 
 ( 
 customer_id 
 , 
 campaign_id 
 ) 
 campaign 
 . 
 bidding_strategy 
 = 
 bidding_strategy_resource_name 
 client 
 . 
 copy_from 
 ( 
 campaign_operation 
 . 
 update_mask 
 , 
 protobuf_helpers 
 . 
 field_mask 
 ( 
 None 
 , 
 campaign 
 . 
 _pb 
 ), 
 ) 
 # Sends the operation in a mutate request. 
 response 
 : 
 MutateCampaignsResponse 
 = 
 campaign_service 
 . 
 mutate_campaigns 
 ( 
 customer_id 
 = 
 customer_id 
 , 
 operations 
 = 
 [ 
 campaign_operation 
 ] 
 ) 
 # Prints the resource name of the updated campaign. 
 print 
 ( 
 "Updated campaign with resource name: " 
 f 
 "' 
 { 
 response 
 . 
 results 
 [ 
 0 
 ] 
 . 
 resource_name 
 } 
 '" 
 ) 
  

Ruby

 def 
  
 attach_cross_account_bidding_strategy_to_campaign 
 ( 
  
 client 
 , 
  
 customer_id 
 , 
  
 campaign_id 
 , 
  
 bidding_strategy_resource_name 
 ) 
  
 operation 
  
 = 
  
 client 
 . 
 operation 
 . 
 update_resource 
 . 
 campaign 
 ( 
  
 client 
 . 
 path 
 . 
 campaign 
 ( 
 customer_id 
 , 
  
 campaign_id 
 )) 
  
 do 
  
 | 
 c 
 | 
  
 c 
 . 
 bidding_strategy 
  
 = 
  
 bidding_strategy_resource_name 
  
 end 
  
 # Sends the operation in a mutate request. 
  
 response 
  
 = 
  
 client 
 . 
 service 
 . 
 campaign 
 . 
 mutate_campaigns 
 ( 
  
 customer_id 
 : 
  
 customer_id 
 , 
  
 operations 
 : 
  
 [ 
 operation 
 ] 
 , 
  
 ) 
  
 puts 
  
 "Updated campaign with resource name: " 
  
 \ 
  
 "` 
 #{ 
 response 
 . 
 results 
 . 
 first 
 . 
 resource_name 
 } 
 `" 
 end  
 
 . 
 rb 
  

Perl

 # Attaches a specified cross-account bidding strategy to a campaign owned by a 
 # specified client customer account. 
 sub 
  
 _attach_cross_account_bidding_strategy_to_campaign 
  
 { 
  
 my 
  
 ( 
 $api_client 
 , 
  
 $customer_id 
 , 
  
 $campaign_id 
 , 
  
 $bidding_strategy_resource_name 
 ) 
  
 = 
  
 @_ 
 ; 
  
 my 
  
 $campaign 
  
 = 
  
 Google::Ads::GoogleAds::V21::Resources:: 
 Campaign 
 - 
> new 
 ({ 
  
 resourceName 
  
 = 
>  
 Google::Ads::GoogleAds::V21::Utils::ResourceNames:: 
 campaign 
 ( 
  
 $customer_id 
 , 
  
 $campaign_id 
  
 ), 
  
 biddingStrategy 
  
 = 
>  
 $bidding_strategy_resource_name 
  
 }); 
  
 my 
  
 $campaign_operation 
  
 = 
  
 Google::Ads::GoogleAds::V21::Services::CampaignService:: 
 CampaignOperation 
 - 
>  
 new 
 ({ 
  
 update 
  
 = 
>  
 $campaign 
 , 
  
 updateMask 
  
 = 
>  
 all_set_fields_of 
 ( 
 $campaign 
 )}); 
  
 my 
  
 $campaigns_response 
  
 = 
  
 $api_client 
 - 
> CampaignService 
 () 
 - 
> mutate 
 ({ 
  
 customerId 
  
 = 
>  
 $customer_id 
 , 
  
 operations 
  
 = 
>  
 [ 
 $campaign_operation 
 ]}); 
  
 printf 
  
 "Updated campaign with resource name '%s'.\n" 
 , 
  
 $campaigns_response 
 - 
> { 
 results 
 }[ 
 0 
 ]{ 
 resourceName 
 }; 
 } 
  
  

Remove bidding strategy

To disassociate a cross-account bidding strategy from a campaign, update the campaign to use a different bidding strategy. Either set its bidding_strategy field to use a different portfolio strategy or use a standard bidding strategy instead.

If a client account is unlinked from its manager, any cross-account bidding strategies shared by that manager will no longer be accessible. Any of the client's campaigns set to use such a bidding strategy will stop serving and must be updated to use a different bidding strategy.

Design a Mobile Site
View Site in Mobile | Classic
Share by: