Campaign-level Conversion Goals

  • Conversion goals in Performance Max guide Google's algorithms for ad serving and budget allocation based on your bidding strategy.

  • By default, Performance Max campaigns use all customer-level conversion goals unless you explicitly apply a subset.

  • To set campaign conversion goals, you retrieve customer conversion goals, create campaign conversion goals with desired biddability settings, and then update them with a mutate request.

  • Setting the biddable field to TRUE for a specific category and origin applies that goal to the campaign, while setting it to FALSE excludes it.

In Performance Max, conversion goals help guide Google's algorithms to optimize ad serving and budget allocation that align with your selected campaign bidding strategy . You can explicitly apply a subset of your customer goals to a Performance Max campaign. If you don't explicitly set conversion goals for a campaign, it defaults to using all customer-level conversion goals.

Follow these steps to set campaign conversion goals for a Performance Max campaign:

  1. Retrieve all CustomerConversionGoals .

      SELECT 
      
     customer_conversion_goal 
     . 
     category 
     , 
      
     customer_conversion_goal 
     . 
     origin 
     FROM 
      
     customer_conversion_goal 
     
    
  2. Create a copy of each CustomerConversionGoal as a CampaignConversionGoal object. If you want to apply a goal to your Performance Max campaign, as determined by the unique combination of category and origin , set the biddable field to TRUE . Otherwise, set biddable to FALSE . The biddable field specifies whether the CampaignConversionGoal should be used.

  3. Issue a mutate request to update all CampaignConversionGoals with the updated biddable field values.

    Java

     /** Retrieves the list of customer conversion goals. */ 
     private 
      
     static 
      
     List<CustomerConversionGoal> 
      
     getCustomerConversionGoals 
     ( 
      
     GoogleAdsClient 
      
     googleAdsClient 
     , 
      
     long 
      
     customerId 
     ) 
      
     { 
      
     String 
      
     query 
      
     = 
      
     "SELECT customer_conversion_goal.category, customer_conversion_goal.origin " 
      
     + 
      
     "FROM customer_conversion_goal" 
     ; 
      
     List<CustomerConversionGoal> 
      
     customerConversionGoals 
      
     = 
      
     new 
      
     ArrayList 
    <> (); 
      
     try 
      
     ( 
     GoogleAdsServiceClient 
      
     googleAdsServiceClient 
      
     = 
      
     googleAdsClient 
     . 
     getLatestVersion 
     (). 
     createGoogleAdsServiceClient 
     ()) 
      
     { 
      
     // The number of conversion goals is typically less than 50, so we use 
      
     // GoogleAdsService.search instead of search_stream. 
      
     SearchPagedResponse 
      
     response 
      
     = 
      
     googleAdsServiceClient 
     . 
     search 
     ( 
     Long 
     . 
     toString 
     ( 
     customerId 
     ), 
      
     query 
     ); 
      
     for 
      
     ( 
     GoogleAdsRow 
      
     googleAdsRow 
      
     : 
      
     response 
     . 
     iterateAll 
     ()) 
      
     { 
      
     customerConversionGoals 
     . 
     add 
     ( 
     googleAdsRow 
     . 
     getCustomerConversionGoal 
     ()); 
      
     } 
      
     } 
      
     return 
      
     customerConversionGoals 
     ; 
     } 
     /** Creates a list of MutateOperations that override customer conversion goals. */ 
     private 
      
     static 
      
     List<MutateOperation> 
      
     createConversionGoalOperations 
     ( 
      
     long 
      
     customerId 
     , 
      
     List<CustomerConversionGoal> 
      
     customerConversionGoals 
     ) 
      
     { 
      
     List<MutateOperation> 
      
     mutateOperations 
      
     = 
      
     new 
      
     ArrayList 
    <> (); 
      
     // 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. 
      
     for 
      
     ( 
     CustomerConversionGoal 
      
     customerConversionGoal 
      
     : 
      
     customerConversionGoals 
     ) 
      
     { 
      
     ConversionActionCategory 
      
     category 
      
     = 
      
     customerConversionGoal 
     . 
     getCategory 
     (); 
      
     ConversionOrigin 
      
     origin 
      
     = 
      
     customerConversionGoal 
     . 
     getOrigin 
     (); 
      
     String 
      
     campaignConversionGoalResourceName 
      
     = 
      
     ResourceNames 
     . 
     campaignConversionGoal 
     ( 
      
     customerId 
     , 
      
     PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID 
     , 
      
     category 
     , 
      
     origin 
     ); 
      
     CampaignConversionGoal 
     . 
     Builder 
      
     campaignConversionGoalBuilder 
      
     = 
      
     CampaignConversionGoal 
     . 
     newBuilder 
     (). 
     setResourceName 
     ( 
     campaignConversionGoalResourceName 
     ); 
      
     // 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 
      
     == 
      
     ConversionActionCategory 
     . 
     PURCHASE 
     && 
     origin 
      
     == 
      
     ConversionOrigin 
     . 
     WEBSITE 
     ) 
      
     { 
      
     campaignConversionGoalBuilder 
     . 
     setBiddable 
     ( 
     true 
     ); 
      
     } 
      
     else 
      
     { 
      
     campaignConversionGoalBuilder 
     . 
     setBiddable 
     ( 
     false 
     ); 
      
     } 
      
     CampaignConversionGoal 
      
     campaignConversionGoal 
      
     = 
      
     campaignConversionGoalBuilder 
     . 
     build 
     (); 
      
     CampaignConversionGoalOperation 
      
     campaignConversionGoalOperation 
      
     = 
      
     CampaignConversionGoalOperation 
     . 
     newBuilder 
     () 
      
     . 
     setUpdate 
     ( 
     campaignConversionGoal 
     ) 
      
     . 
     setUpdateMask 
     ( 
     FieldMasks 
     . 
     allSetFieldsOf 
     ( 
     campaignConversionGoal 
     )) 
      
     . 
     build 
     (); 
      
     mutateOperations 
     . 
     add 
     ( 
      
     MutateOperation 
     . 
     newBuilder 
     () 
      
     . 
     setCampaignConversionGoalOperation 
     ( 
     campaignConversionGoalOperation 
     ) 
      
     . 
     build 
     ()); 
      
     } 
      
     return 
      
     mutateOperations 
     ; 
     } 
      
      
    

    C#

     /// <summary> 
     /// Creates a MutateOperation that links an asset to an asset group. 
     /// </summary> 
     /// <param name="fieldType">The field type of the asset to be linked.</param> 
     /// <param name="linkedEntityResourceName">The resource name of the entity (asset group or 
     /// campaign) to link the asset to.</param> 
     /// <param name="assetResourceName">The resource name of the text asset to be 
     /// linked.</param> 
     /// <param name="brandGuidelinesEnabled">Whether or not to enable brand guidelines.</param> 
     /// <returns>A MutateOperation that links an asset to an asset group.</returns> 
     private 
      
     MutateOperation 
      
     CreateLinkAssetOperation 
     ( 
      
     AssetFieldType 
      
     fieldType 
     , 
      
     string 
      
     linkedEntityResourceName 
     , 
      
     string 
      
     assetResourceName 
     , 
      
     bool 
      
     brandGuidelinesEnabled 
      
     = 
      
     false 
     ) 
     { 
      
     if 
      
     ( 
     brandGuidelinesEnabled 
     ) 
      
     { 
      
     return 
      
     new 
      
     MutateOperation 
     () 
      
     { 
      
     CampaignAssetOperation 
      
     = 
      
     new 
      
     CampaignAssetOperation 
     () 
      
     { 
      
     Create 
      
     = 
      
     new 
      
     CampaignAsset 
     () 
      
     { 
      
     FieldType 
      
     = 
      
     fieldType 
     , 
      
     Campaign 
      
     = 
      
     linkedEntityResourceName 
     , 
      
     Asset 
      
     = 
      
     assetResourceName 
      
     } 
      
     } 
      
     }; 
      
     } 
      
     else 
      
     { 
      
     return 
      
     new 
      
     MutateOperation 
     () 
      
     { 
      
     AssetGroupAssetOperation 
      
     = 
      
     new 
      
     AssetGroupAssetOperation 
     () 
      
     { 
      
     Create 
      
     = 
      
     new 
      
     AssetGroupAsset 
     () 
      
     { 
      
     FieldType 
      
     = 
      
     fieldType 
     , 
      
     AssetGroup 
      
     = 
      
     linkedEntityResourceName 
     , 
      
     Asset 
      
     = 
      
     assetResourceName 
      
     } 
      
     } 
      
     }; 
      
     } 
     } 
      
      
    

    PHP

     private static function getCustomerConversionGoals( 
     GoogleAdsClient $googleAdsClient, 
     int $customerId 
     ): array { 
     $customerConversionGoals = []; 
     $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient(); 
     // Creates a query that retrieves all customer conversion goals. 
     $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 a search request 
     // instead of search stream. 
     $response = 
     $googleAdsServiceClient->search(SearchGoogleAdsRequest::build($customerId, $query)); 
     // Iterates over all rows in all pages and builds the list of conversion goals. 
     foreach ($response->iterateAllElements() as $googleAdsRow) { 
     /** @var GoogleAdsRow $googleAdsRow */ 
     $customerConversionGoals[] = [ 
     'category' => $googleAdsRow->getCustomerConversionGoal()->getCategory(), 
     'origin' => $googleAdsRow->getCustomerConversionGoal()->getOrigin() 
     ]; 
     } 
     return $customerConversionGoals; 
     } 
     /** 
     * Creates a list of MutateOperations that override customer conversion goals. 
     * 
     * @param int $customerId the customer ID 
     * @param array $customerConversionGoals the list of customer conversion goals that will be 
     *      overridden 
     * @return MutateOperation[] a list of MutateOperations that update campaign conversion goals 
     */ 
     private static function createConversionGoalOperations( 
     int $customerId, 
     array $customerConversionGoals 
     ): array { 
     $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. 
     foreach ($customerConversionGoals as $customerConversionGoal) { 
     $campaignConversionGoal = new CampaignConversionGoal([ 
     'resource_name' => ResourceNames::forCampaignConversionGoal( 
     $customerId, 
     self::PERFORMANCE_MAX_CAMPAIGN_TEMPORARY_ID, 
     ConversionActionCategory::name($customerConversionGoal['category']), 
     ConversionOrigin::name($customerConversionGoal['origin']) 
     ) 
     ]); 
     // Changes the biddability for the campaign conversion goal. 
     // Sets biddability to true for the desired (category, origin). 
     // Sets 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 ( 
     $customerConversionGoal["category"] === ConversionActionCategory::PURCHASE 
     && $customerConversionGoal["origin"] === ConversionOrigin::WEBSITE 
     ) { 
     $campaignConversionGoal->setBiddable(true); 
     } else { 
     $campaignConversionGoal->setBiddable(false); 
     } 
     $operations[] = new MutateOperation([ 
     'campaign_conversion_goal_operation' => new CampaignConversionGoalOperation([ 
     'update' => $campaignConversionGoal, 
     // Sets 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. 
     'update_mask' => FieldMasks::allSetFieldsOf($campaignConversionGoal) 
     ]) 
     ]); 
     } 
     return $operations; 
     }  
     
    

Python

 def 
  
 get_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 customer 
 conversion goals. 
 """ 
 ga_service 
 : 
 GoogleAdsServiceClient 
 = 
 client 
 . 
 get_service 
 ( 
 "GoogleAdsService" 
 ) 
 customer_conversion_goals 
 : 
 List 
 [ 
 Dict 
 [ 
 str 
 , 
 Union 
 [ 
 ConversionActionCategoryEnum 
 . 
 ConversionActionCategory 
 , 
 ConversionOriginEnum 
 . 
 ConversionOrigin 
 , 
 ], 
 ] 
 ] 
 = 
 [] 
 query 
 : 
 str 
 = 
 """ 
 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 instead of search_stream. 
 search_request 
 : 
 SearchGoogleAdsRequest 
 = 
 client 
 . 
 get_type 
 ( 
 "SearchGoogleAdsRequest" 
 ) 
 search_request 
 . 
 customer_id 
 = 
 customer_id 
 search_request 
 . 
 query 
 = 
 query 
 results 
 : 
 SearchGoogleAdsResponse 
 = 
 ga_service 
 . 
 search 
 ( 
 request 
 = 
 search_request 
 ) 
 # Iterate over the results and build the list of conversion goals. 
 for 
 row 
 in 
 results 
 : 
 customer_conversion_goals 
 . 
 append 
 ( 
 { 
 "category" 
 : 
 row 
 . 
 customer_conversion_goal 
 . 
 category 
 , 
 "origin" 
 : 
 row 
 . 
 customer_conversion_goal 
 . 
 origin 
 , 
 } 
 ) 
 return 
 customer_conversion_goals 
 def 
  
 create_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 that 
 will 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. 
 for 
 customer_goal_dict 
 in 
 customer_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 
 . 
 PURCHASE 
 and 
 origin_enum_value 
 == 
 client 
 . 
 enums 
 . 
 ConversionOriginEnum 
 . 
 WEBSITE 
 ): 
 biddable 
 = 
 True 
 else 
 : 
 biddable 
 = 
 False 
 campaign_conversion_goal 
 . 
 biddable 
 = 
 biddable 
 field_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 
 ) 
 return 
 operations  
 
 . 
 py 

Ruby

 def 
  
 _get_customer_conversion_goals 
 ( 
 client 
 , 
  
 customer_id 
 ) 
  
 query 
  
 = 
  
<< ~ 
 EOD 
  
 SELECT 
  
 customer_conversion_goal 
 . 
 category 
 , 
  
 customer_conversion_goal 
 . 
 origin 
  
 FROM 
  
 customer_conversion_goal 
  
 EOD 
  
 customer_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 
 . 
 each 
  
 do 
  
 | 
 row 
 | 
  
 customer_conversion_goals 
 << 
 { 
  
 "category" 
  
 = 
>  
 row 
 . 
 customer_conversion_goal 
 . 
 category 
 , 
  
 "origin" 
  
 = 
>  
 row 
 . 
 customer_conversion_goal 
 . 
 origin 
  
 } 
  
 end 
  
 customer_conversion_goals 
 end 
 def 
  
 create_conversion_goal_operations 
 ( 
 client 
 , 
  
 customer_id 
 , 
  
 customer_conversion_goals 
 ) 
  
 campaign_conversion_goal_service 
  
 = 
  
 client 
 . 
 service 
 . 
 campaign_conversion_goal 
  
 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. 
  
 customer_conversion_goals 
 . 
 each 
  
 do 
  
 | 
 customer_conversion_goal 
 | 
  
 operations 
 << 
 client 
 . 
 operation 
 . 
 mutate 
  
 do 
  
 | 
 m 
 | 
  
 m 
 . 
 campaign_conversion_goal_operation 
  
 = 
  
 client 
 . 
 operation 
 . 
 campaign_conversion_goal 
  
 do 
  
 | 
 op 
 | 
  
 op 
 . 
 update 
  
 = 
  
 client 
 . 
 resource 
 . 
 campaign_conversion_goal 
  
 do 
  
 | 
 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 
 ) 
  
 end 
  
 op 
 . 
 update_mask 
  
 = 
  
 Google 
 :: 
 Ads 
 :: 
 GoogleAds 
 :: 
 FieldMaskUtil 
 . 
 all_set_fields_of 
 ( 
 op 
 . 
 update 
 ) 
  
 end 
  
 end 
  
 end 
  
 operations 
 end  
 
 . 
 rb 
  

Perl

 sub 
  
 get_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. 
  
 foreach 
  
 my 
  
 $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. 
 sub 
  
 create_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. 
  
 foreach 
  
 my 
  
 $customer_conversion_goal 
  
 ( 
 @$customer_conversion_goals 
 ) 
  
 { 
  
 my 
  
 $campaign_conversion_goal 
  
 = 
  
 Google::Ads::GoogleAds::V22::Resources:: 
 CampaignConversionGoal 
 - 
> new 
 ({ 
  
 resourceName 
  
 = 
>  
 Google::Ads::GoogleAds::V22::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 
 } 
  
 eq 
  
 PURCHASE 
 && 
 $customer_conversion_goal 
 - 
> { 
 origin 
 } 
  
 eq 
  
 WEBSITE 
 ) 
  
 { 
  
 $campaign_conversion_goal 
 - 
> { 
 biddable 
 } 
  
 = 
  
 "true" 
 ; 
  
 } 
  
 else 
  
 { 
  
 $campaign_conversion_goal 
 - 
> { 
 biddable 
 } 
  
 = 
  
 "false" 
 ; 
  
 } 
  
 push 
  
 @$operations 
 , 
  
 Google::Ads::GoogleAds::V22::Services::GoogleAdsService:: 
 MutateOperation 
  
 - 
> new 
 ({ 
  
 campaignConversionGoalOperation 
  
 = 
>  
 Google::Ads::GoogleAds::V22::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 
 ; 
 } 
  
  
Create a Mobile Website
View Site in Mobile | Classic
Share by: