最佳化分數和最佳化建議

影片:深入探索

建議可以透過下列幾種方式改善廣告活動成效:

  • 推出新的相關功能
  • 改善出價、關鍵字和廣告,善用每一分預算
  • 提升廣告活動的整體成效和效益

如要提高最佳化分數,您可以使用 RecommendationService 擷取建議,據此套用或略過建議。從 Google Ads API v15 開始,您也可以使用 RecommendationSubscriptionService 訂閱自動套用最佳化建議。

最佳化分數

影片:最佳化分數

最佳化分數預估 Google Ads 帳戶的預期成效,可在 CustomerCampaign 層級查看。

Customer.optimization_score_weight 僅適用於非管理員帳戶,可用於計算多個帳戶的整體最佳化分數。擷取帳戶的最佳化分數和最佳化分數權重,然後將兩者相乘 (Customer.optimization_score * Customer.optimization_score_weight),藉此計算整體最佳化分數。

customercampaign 報表提供幾種最佳化相關指標:

  1. metrics.optimization_score_url 會提供帳戶的深層連結,以便在 Google Ads UI 中查看相關建議的資訊。
  2. metrics.optimization_score_uplift 會顯示套用所有相關建議後,最佳化分數的上升幅度。這個值是依據所有可用建議整體估算而得,而非每項建議的升幅分數總和。

如要為傳回的建議分組及排序,您可以在查詢中使用 segments.recommendation_type 按建議類型區隔這兩項指標。

建議內容類型

完整支援的建議類型

RecommendationType 說明
CAMPAIGN_BUDGET 修正受到預算限制的廣告活動
KEYWORD 新增關鍵字
TEXT_AD 新增廣告建議
TARGET_CPA_OPT_IN 採用目標單次轉換出價
MAXIMIZE_CONVERSIONS_OPT_IN 使用「盡量爭取轉換」出價
MAXIMIZE_CONVERSION_VALUE_OPT_IN 採用「盡量提高轉換價值」出價
ENHANCED_CPC_OPT_IN 使用「成本效益管理系統」出價
MAXIMIZE_CLICKS_OPT_IN 使用「盡量爭取點擊」出價
OPTIMIZE_AD_ROTATION 使用最佳化廣告輪播
MOVE_UNUSED_BUDGET 將未用到的預算挪給受限的預算
TARGET_ROAS_OPT_IN 採用「目標廣告投資報酬率」出價
FORECASTING_CAMPAIGN_BUDGET 修正未來預期將受到預算限制的廣告活動
RESPONSIVE_SEARCH_AD 新增回應式搜尋廣告
MARGINAL_ROI_CAMPAIGN_BUDGET 調整廣告活動預算以提高投資報酬率
USE_BROAD_MATCH_KEYWORD 針對以轉換為準的廣告活動搭配自動出價,使用廣泛比對
RESPONSIVE_SEARCH_AD_ASSET 為廣告新增回應式搜尋廣告素材資源
RESPONSIVE_SEARCH_AD_IMPROVE_AD_STRENGTH 改善回應式搜尋廣告的強度
DISPLAY_EXPANSION_OPT_IN 更新廣告活動以使用「採用多媒體廣告聯播網」
SEARCH_PARTNERS_OPT_IN 透過 Google 搜尋夥伴擴大觸及範圍
CUSTOM_AUDIENCE_OPT_IN 建立自訂目標對象
IMPROVE_DISCOVERY_AD_STRENGTH 改善需求開發廣告活動中的廣告優異度
UPGRADE_SMART_SHOPPING_CAMPAIGN_TO_PERFORMANCE_MAX 將智慧購物廣告活動升級為最高成效廣告活動
UPGRADE_LOCAL_CAMPAIGN_TO_PERFORMANCE_MAX 將舊版地區廣告活動升級為最高成效廣告活動
SHOPPING_MIGRATE_REGULAR_SHOPPING_CAMPAIGN_OFFERS_TO_PERFORMANCE_MAX 將一般購物廣告活動指定的優惠遷移至現有的最高成效廣告活動
MIGRATE_DYNAMIC_SEARCH_ADS_CAMPAIGN_TO_PERFORMANCE_MAX 將動態搜尋廣告遷移至最高成效廣告活動
PERFORMANCE_MAX_OPT_IN 在帳戶中建立最高成效廣告活動
IMPROVE_PERFORMANCE_MAX_AD_STRENGTH 將最高成效廣告活動的素材資源群組優異度提升至「極佳」評分
PERFORMANCE_MAX_FINAL_URL_OPT_IN 啟用最高成效廣告活動的「最終到達網址擴展」功能
RAISE_TARGET_CPA_BID_TOO_LOW 如果出價太低,或轉換次數過少,請提高目標單次轉換出價
FORECASTING_SET_TARGET_ROAS 如果季節性事件預計會提高流量,請提前提高預算,並將出價策略從「盡量提高轉換價值」改為「目標廣告投資報酬率」
LEAD_FORM 在廣告活動中加入待開發客戶表單素材資源
CALLOUT_ASSET 在廣告活動或客戶層級加入摘要素材資源
SITELINK_ASSET 在廣告活動或顧客層級加入網站連結素材資源
CALL_ASSET 在廣告活動或客戶層級新增電話素材資源
SHOPPING_ADD_AGE_GROUP 為因缺少年齡層而降低排名的商品,新增年齡層屬性
SHOPPING_ADD_COLOR 為因缺少顏色而降低排名的優惠新增顏色
SHOPPING_ADD_GENDER 為因缺少性別而降低排名的優惠,新增性別
SHOPPING_ADD_GTIN 為因缺少全球交易品項識別碼而降低排名的商品,新增全球交易品項識別碼 (GTIN)
SHOPPING_ADD_MORE_IDENTIFIERS 在因缺少 ID 而降低排名的優惠中,新增更多 ID
SHOPPING_ADD_SIZE 為因缺少尺寸而降低排名的商品,新增尺寸
SHOPPING_ADD_PRODUCTS_TO_CAMPAIGN 為廣告活動新增產品
SHOPPING_FIX_DISAPPROVED_PRODUCTS 修正遭拒登的產品
SHOPPING_TARGET_ALL_OFFERS 建立通用產品廣告活動,指定所有優惠
SHOPPING_FIX_SUSPENDED_MERCHANT_CENTER_ACCOUNT 修正 Merchant Center 帳戶停權問題
SHOPPING_FIX_MERCHANT_CENTER_ACCOUNT_SUSPENSION_WARNING 修正 Merchant Center 帳戶停權警告問題
DYNAMIC_IMAGE_EXTENSION_OPT_IN 啟用帳戶的動態圖片額外資訊
RAISE_TARGET_CPA 提高目標單次轉換出價
LOWER_TARGET_ROAS 目標廣告投資報酬率降幅
FORECASTING_SET_TARGET_CPA 在預計會提高流量的季節性事件前,為尚未指定的廣告活動設定目標單次轉換出價
SET_TARGET_CPA 為沒有指定的廣告活動設定目標單次轉換出價
SET_TARGET_ROAS 為尚未指定的廣告活動設定目標廣告投資報酬率
REFRESH_CUSTOMER_MATCH_LIST 更新過去 90 天內未更新的顧客名單
IMPROVE_GOOGLE_TAG_COVERAGE 在其他網頁上部署 Google 代碼
CALLOUT_EXTENSION (已淘汰) 已淘汰,請改用 CALLOUT_ASSET
SITELINK_EXTENSION (已淘汰) 已淘汰,請改用 SITELINK_ASSET
CALL_EXTENSION (已淘汰) 已淘汰,請改用 CALL_ASSET
KEYWORD_MATCH_TYPE (已淘汰) 已淘汰,請改用 USE_BROAD_MATCH_KEYWORD

觀看影片瞭解詳情

處理不支援的類型

擷取建議

影片:即時程式碼

如同 Google Ads API 中的大多數其他實體,系統會使用 GoogleAdsService.SearchStream 搭配 Google Ads 查詢語言查詢來擷取 Recommendation 物件

針對每種建議,系統會在建議專屬的欄位中提供詳細資料。舉例來說,campaign_budget_recommendation 欄位中提供 CAMPAIGN_BUDGET 建議詳細資料,並包裝在 CampaignBudgetRecommendation 物件中。

recommendation 聯集欄位中,找到所有建議專屬的欄位。

建議的影響

部分建議類型會在建議的 impact 欄位中填入資料。RecommendationImpact 包含套用建議後對帳戶成效的預估影響。impact.base_metricsimpact.potential_metrics 欄位提供下列建議指標

  • impressions

  • clicks

  • cost_micros

  • conversions

  • all_conversions (自 Google Ads API v16 版開始提供)

  • video_views

程式碼範例

下列程式碼範例會從帳戶中擷取 KEYWORD 類型的所有可用和已關閉的建議,並列印部分詳細資料:

Java

try (GoogleAdsServiceClient googleAdsServiceClient =
        googleAdsClient.getLatestVersion().createGoogleAdsServiceClient();
    RecommendationServiceClient recommendationServiceClient =
        googleAdsClient.getLatestVersion().createRecommendationServiceClient()) {
  // Creates a query that retrieves keyword recommendations.
  String query =
      "SELECT recommendation.resource_name, "
          + "  recommendation.campaign, "
          + "  recommendation.keyword_recommendation "
          + "FROM recommendation "
          + "WHERE recommendation.type = KEYWORD";
  // Constructs the SearchGoogleAdsStreamRequest.
  SearchGoogleAdsStreamRequest request =
      SearchGoogleAdsStreamRequest.newBuilder()
          .setCustomerId(Long.toString(customerId))
          .setQuery(query)
          .build();

  // Issues the search stream request to detect keyword recommendations that exist for the
  // customer account.
  ServerStream<SearchGoogleAdsStreamResponse> stream =
      googleAdsServiceClient.searchStreamCallable().call(request);

  // Creates apply operations for all the recommendations found.
  List<ApplyRecommendationOperation> applyRecommendationOperations = new ArrayList<>();
  for (SearchGoogleAdsStreamResponse response : stream) {
    for (GoogleAdsRow googleAdsRow : response.getResultsList()) {
      Recommendation recommendation = googleAdsRow.getRecommendation();
      System.out.printf(
          "Keyword recommendation '%s' was found for campaign '%s'%n",
          recommendation.getResourceName(), recommendation.getCampaign());
      KeywordInfo keyword = recommendation.getKeywordRecommendation().getKeyword();
      System.out.printf("\tKeyword = '%s'%n", keyword.getText());
      System.out.printf("\tMatch type = '%s'%n", keyword.getMatchType());

      // Creates an ApplyRecommendationOperation that will apply this recommendation, and adds
      // it to the list of operations.
      applyRecommendationOperations.add(buildRecommendationOperation(recommendation));
    }
  }
      

C#

// Get the GoogleAdsServiceClient.
GoogleAdsServiceClient googleAdsService = client.GetService(
    Services.V16.GoogleAdsService);

// Creates a query that retrieves keyword recommendations.
string query = "SELECT recommendation.resource_name, " +
    "recommendation.campaign, recommendation.keyword_recommendation " +
    "FROM recommendation WHERE " +
    $"recommendation.type = KEYWORD";

List<ApplyRecommendationOperation> operations =
    new List<ApplyRecommendationOperation>();

try
{
    // Issue a search request.
    googleAdsService.SearchStream(customerId.ToString(), query,
        delegate (SearchGoogleAdsStreamResponse resp)
        {
            Console.WriteLine($"Found {resp.Results.Count} recommendations.");
            foreach (GoogleAdsRow googleAdsRow in resp.Results)
            {
                Recommendation recommendation = googleAdsRow.Recommendation;
                Console.WriteLine("Keyword recommendation " +
                    $"{recommendation.ResourceName} was found for campaign " +
                    $"{recommendation.Campaign}.");

                if (recommendation.KeywordRecommendation != null)
                {
                    KeywordInfo keyword =
                        recommendation.KeywordRecommendation.Keyword;
                    Console.WriteLine($"Keyword = {keyword.Text}, type = " +
                        "{keyword.MatchType}");
                }

                operations.Add(
                    BuildApplyRecommendationOperation(recommendation.ResourceName)
                );
            }
        }
    );
}
catch (GoogleAdsException e)
{
    Console.WriteLine("Failure:");
    Console.WriteLine($"Message: {e.Message}");
    Console.WriteLine($"Failure: {e.Failure}");
    Console.WriteLine($"Request ID: {e.RequestId}");
    throw;
}
      

PHP

$googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
// Creates a query that retrieves keyword recommendations.
$query = 'SELECT recommendation.resource_name, recommendation.campaign, '
    . 'recommendation.keyword_recommendation '
    . 'FROM recommendation '
    . 'WHERE recommendation.type = KEYWORD ';
// Issues a search request to detect keyword recommendations that exist for the
// customer account.
$response =
    $googleAdsServiceClient->search(SearchGoogleAdsRequest::build($customerId, $query));

$operations = [];
// Iterates over all rows in all pages and prints the requested field values for
// the recommendation in each row.
foreach ($response->iterateAllElements() as $googleAdsRow) {
    /** @var GoogleAdsRow $googleAdsRow */
    $recommendation = $googleAdsRow->getRecommendation();
    printf(
        "Keyword recommendation with resource name '%s' was found for campaign "
        . "with resource name '%s':%s",
        $recommendation->getResourceName(),
        $recommendation->getCampaign(),
        PHP_EOL
    );
    if (!is_null($recommendation->getKeywordRecommendation())) {
        $keyword = $recommendation->getKeywordRecommendation()->getKeyword();
        printf(
            "\tKeyword = '%s'%s\ttype = '%s'%s",
            $keyword->getText(),
            PHP_EOL,
            KeywordMatchType::name($keyword->getMatchType()),
            PHP_EOL
        );
    }
    // Creates an ApplyRecommendationOperation that will be used to apply this
    // recommendation, and adds it to the list of operations.
    $operations[] = self::buildRecommendationOperation($recommendation->getResourceName());
}
      

Python

googleads_service = client.get_service("GoogleAdsService")
query = f"""
    SELECT
      recommendation.campaign,
      recommendation.keyword_recommendation
    FROM recommendation
    WHERE
      recommendation.type = KEYWORD"""

# Detects keyword recommendations that exist for the customer account.
response = googleads_service.search(customer_id=customer_id, query=query)

operations = []
for row in response.results:
    recommendation = row.recommendation
    print(
        f"Keyword recommendation ('{recommendation.resource_name}') "
        f"was found for campaign '{recommendation.campaign}."
    )

    keyword = recommendation.keyword_recommendation.keyword
    print(
        f"\tKeyword = '{keyword.text}'\n" f"\tType = '{keyword.match_type}'"
    )

    # Create an ApplyRecommendationOperation that will be used to apply
    # this recommendation, and add it to the list of operations.
    operations.append(
        build_recommendation_operation(client, recommendation.resource_name)
    )
      

Ruby

query = <<~QUERY
  SELECT recommendation.resource_name, recommendation.campaign,
      recommendation.keyword_recommendation
  FROM recommendation
  WHERE recommendation.type = KEYWORD
QUERY

google_ads_service = client.service.google_ads

response = google_ads_service.search(
  customer_id: customer_id,
  query: query,
)

operations = response.each do |row|
  recommendation = row.recommendation

  puts "Keyword recommendation ('#{recommendation.resource_name}') was found for "\
    "campaign '#{recommendation.campaign}'."

  if recommendation.keyword_recommendation
    keyword = recommendation.keyword_recommendation.keyword
    puts "\tKeyword = '#{keyword.text}'"
    puts "\ttype = '#{keyword.match_type}'"
  end

  build_recommendation_operation(client, recommendation.resource_name)
end
      

Perl

# Create the search query.
my $search_query =
  "SELECT recommendation.resource_name, " .
  "recommendation.campaign, recommendation.keyword_recommendation " .
  "FROM recommendation " .
  "WHERE recommendation.type = KEYWORD";

# Get the GoogleAdsService.
my $google_ads_service = $api_client->GoogleAdsService();

my $search_stream_handler =
  Google::Ads::GoogleAds::Utils::SearchStreamHandler->new({
    service => $google_ads_service,
    request => {
      customerId => $customer_id,
      query      => $search_query
    }});

# Create apply operations for all the recommendations found.
my $apply_recommendation_operations = ();
$search_stream_handler->process_contents(
  sub {
    my $google_ads_row = shift;
    my $recommendation = $google_ads_row->{recommendation};
    printf "Keyword recommendation '%s' was found for campaign '%s'.\n",
      $recommendation->{resourceName}, $recommendation->{campaign};
    my $keyword = $recommendation->{keywordRecommendation}{keyword};
    printf "\tKeyword = '%s'\n",    $keyword->{text};
    printf "\tMatch type = '%s'\n", $keyword->{matchType};
    # Creates an ApplyRecommendationOperation that will apply this recommendation, and adds
    # it to the list of operations.
    push @$apply_recommendation_operations,
      build_recommendation_operation($recommendation);
  });
      

採取行動

擷取到的任何建議都可以套用或關閉。

視推薦類型而定,建議可能會每天或甚至每天多次變化。發生這種情況時,推薦物件的 resource_name 可能會在擷取建議後一併過時。

擷取完畢後,最好立即採取行動。

套用最佳化建議

影片:套用最佳化建議

您可以使用 RecommendationServiceApplyRecommendation 方法,套用有效或已關閉的建議。

推薦類型可包含必要或選用參數。大多數建議都有預設使用的建議值。

並非所有建議類型都支援設定自動套用建議的帳戶。不過,您可以為 Google Ads API 完整支援的最佳化建議類型導入類似的行為。詳情請參閱 DetectAndApplyRecommendations 程式碼範例

使用 ApplyRecommendationOperationapply_parameters 聯集欄位,套用特定參數值的建議。每種建議類型都有各自的欄位。未列在 apply_parameters 欄位中的建議類型則不使用這些參數值。

程式碼範例

以下程式碼示範如何建構 ApplyRecommendationOperation,以及如何覆寫建議的值,以便使用自己的值。

Java

/** Creates and returns an ApplyRecommendationOperation to apply the given recommendation. */
private ApplyRecommendationOperation buildRecommendationOperation(Recommendation recommendation) {
  // If you have a recommendation ID instead of a resource name, you can create a resource name
  // like this:
  // String resourceName = ResourceNames.recommendation(customerId, recommendationId);

  // Creates a builder to construct the operation.
  Builder operationBuilder = ApplyRecommendationOperation.newBuilder();

  // Each recommendation type has optional parameters to override the recommended values. Below is
  // an example showing how to override a recommended ad when a TextAdRecommendation is applied.
  // operationBuilder.getTextAdBuilder().getAdBuilder().setResourceName("INSERT_AD_RESOURCE_NAME");

  // Sets the operation's resource name to the resource name of the recommendation to apply.
  operationBuilder.setResourceName(recommendation.getResourceName());
  return operationBuilder.build();
}
      

C#

private ApplyRecommendationOperation BuildApplyRecommendationOperation(
    string recommendationResourceName
)
{
    // If you have a recommendation_id instead of the resource_name you can create a
    // resource name from it like this:
    // string recommendationResourceName =
    //    ResourceNames.Recommendation(customerId, recommendationId)

    // Each recommendation type has optional parameters to override the recommended values.
    // This is an example to override a recommended ad when a TextAdRecommendation is
    // applied.
    // For details, please read
    // https://developers.google.com/google-ads/api/reference/rpc/latest/ApplyRecommendationOperation.
    /*
    Ad overridingAd = new Ad()
    {
        Id = "INSERT_AD_ID_AS_LONG_HERE"
    };
    applyRecommendationOperation.TextAd = new TextAdParameters()
    {
        Ad = overridingAd
    };
    */

    ApplyRecommendationOperation applyRecommendationOperation =
    new ApplyRecommendationOperation()
    {
        ResourceName = recommendationResourceName
    };

    return applyRecommendationOperation;
}
      

PHP

private static function buildRecommendationOperation(
    string $recommendationResourceName
): ApplyRecommendationOperation {
    // If you have a recommendation_id instead of the resource name, you can create a resource
    // name from it like this:
    /*
    $recommendationResourceName =
        ResourceNames::forRecommendation($customerId, $recommendationId);
    */

    // Each recommendation type has optional parameters to override the recommended values.
    // This is an example to override a recommended ad when a TextAdRecommendation is applied.
    // For details, please read
    // https://developers.google.com/google-ads/api/reference/rpc/latest/ApplyRecommendationOperation.
    /*
    $overridingAd = new Ad([
        'id' => 'INSERT_AD_ID_AS_INTEGER_HERE'
    ]);
    $applyRecommendationOperation->setTextAd(new TextAdParameters(['ad' => $overridingAd]));
    */

    // Issues a mutate request to apply the recommendation.
    $applyRecommendationOperation = new ApplyRecommendationOperation();
    $applyRecommendationOperation->setResourceName($recommendationResourceName);
    return $applyRecommendationOperation;
}
      

Python

def build_recommendation_operation(client, recommendation):
    """Creates a ApplyRecommendationOperation to apply the given recommendation.

    Args:
        client: an initialized GoogleAdsClient instance.
        customer_id: a client customer ID.
        recommendation: a resource name for the recommendation to be applied.
    """
    # If you have a recommendation ID instead of a resource name, you can create
    # a resource name like this:
    #
    # googleads_service = client.get_service("GoogleAdsService")
    # resource_name = googleads_service.recommendation_path(
    #   customer_id, recommendation.id
    # )

    operation = client.get_type("ApplyRecommendationOperation")

    # Each recommendation type has optional parameters to override the
    # recommended values. Below is an example showing how to override a
    # recommended ad when a TextAdRecommendation is applied.
    #
    # operation.text_ad.ad.resource_name = "INSERT_AD_RESOURCE_NAME"
    #
    # For more details, see:
    # https://developers.google.com/google-ads/api/reference/rpc/latest/ApplyRecommendationOperation#apply_parameters

    operation.resource_name = recommendation
    return operation
      

Ruby

def build_recommendation_operation(client, recommendation)
  # If you have a recommendation_id instead of the resource_name
  # you can create a resource name from it like this:
  # recommendation_resource =
  #    client.path.recommendation(customer_id, recommendation_id)

  operations = client.operation.apply_recommendation
  operations.resource_name = recommendation_resource

  # Each recommendation type has optional parameters to override the recommended
  # values. This is an example to override a recommended ad when a
  # TextAdRecommendation is applied.
  #
  # text_ad_parameters = client.resource.text_ad_parameters do |tap|
  #   tap.ad = client.resource.ad do |ad|
  #     ad.id = "INSERT_AD_ID_AS_INTEGER_HERE"
  #   end
  # end
  # operation.text_ad = text_ad_parameters
  #
  # For more details, see:
  # https://developers.google.com/google-ads/api/reference/rpc/latest/ApplyRecommendationOperation#apply_parameters

  return operation
end
      

Perl

sub build_recommendation_operation {
  my ($recommendation) = @_;

  # If you have a recommendation ID instead of a resource name, you can create a resource
  # name like this:
  # my $recommendation_resource_name =
  #   Google::Ads::GoogleAds::V16::Utils::ResourceNames::recommendation(
  #   $customer_id, $recommendation_id);

  # Each recommendation type has optional parameters to override the recommended values.
  # Below is an example showing how to override a recommended ad when a TextAdRecommendation
  # is applied.
  # my $overriding_ad = Google::Ads::GoogleAds::V16::Resources::Ad->new({
  #   id => "INSERT_AD_ID_AS_INTEGER_HERE"
  # });
  # my $text_ad_parameters =
  #   Google::Ads::GoogleAds::V16::Services::RecommendationService::TextAdParameters
  #   ->new({ad => $overriding_ad});
  # $apply_recommendation_operation->{textAd} = $text_ad_parameters;

  # Create an apply recommendation operation.
  my $apply_recommendation_operation =
    Google::Ads::GoogleAds::V16::Services::RecommendationService::ApplyRecommendationOperation
    ->new({
      resourceName => $recommendation->{resourceName}});

  return $apply_recommendation_operation;
}
      

下一個範例會呼叫 ApplyRecommendation,傳送上述程式碼中建立的套用建議作業。

Java

// Issues a mutate request to apply the recommendations.
ApplyRecommendationResponse applyRecommendationsResponse =
    recommendationServiceClient.applyRecommendation(
        Long.toString(customerId), applyRecommendationOperations);
for (ApplyRecommendationResult applyRecommendationResult :
    applyRecommendationsResponse.getResultsList()) {
  System.out.printf(
      "Applied recommendation with resource name: '%s'.%n",
      applyRecommendationResult.getResourceName());
}
      

C#

private void ApplyRecommendation(GoogleAdsClient client, long customerId,
    List<ApplyRecommendationOperation> operations)
{
    // Get the RecommendationServiceClient.
    RecommendationServiceClient recommendationService = client.GetService(
        Services.V16.RecommendationService);

    ApplyRecommendationRequest applyRecommendationRequest = new ApplyRecommendationRequest()
    {
        CustomerId = customerId.ToString(),
    };

    applyRecommendationRequest.Operations.AddRange(operations);

    ApplyRecommendationResponse response =
        recommendationService.ApplyRecommendation(applyRecommendationRequest);
    foreach (ApplyRecommendationResult result in response.Results)
    {
        Console.WriteLine("Applied a recommendation with resource name: " +
            result.ResourceName);
    }
}
      

PHP

private static function applyRecommendations(
    GoogleAdsClient $googleAdsClient,
    int $customerId,
    array $operations
): void {
    // Issues a mutate request to apply the recommendations.
    $recommendationServiceClient = $googleAdsClient->getRecommendationServiceClient();
    $response = $recommendationServiceClient->applyRecommendation(
        ApplyRecommendationRequest::build($customerId, $operations)
    );
    foreach ($response->getResults() as $appliedRecommendation) {
        /** @var Recommendation $appliedRecommendation */
        printf(
            "Applied a recommendation with resource name: '%s'.%s",
            $appliedRecommendation->getResourceName(),
            PHP_EOL
        );
    }
}
      

Python

def apply_recommendations(client, customer_id, operations):
    """Applies a batch of recommendations.

    Args:
        client: an initialized GoogleAdsClient instance.
        customer_id: a client customer ID.
        operations: a list of ApplyRecommendationOperation messages.
    """
    # Issues a mutate request to apply the recommendations.
    recommendation_service = client.get_service("RecommendationService")
    response = recommendation_service.apply_recommendation(
        customer_id=customer_id, operations=operations
    )

    for result in response.results:
        print(
            "Applied a recommendation with resource name: "
            f"'{result[0].resource_name}'."
        )
      

Ruby

def apply_recommendations(client, customer_id, operations)
  # Issues a mutate request to apply the recommendation.
  recommendation_service = client.service.recommendation

  response = recommendation_service.apply_recommendation(
    customer_id: customer_id,
    operations: [operations],
  )

  response.results.each do |applied_recommendation|
    puts "Applied recommendation with resource name: '#{applied_recommendation.resource_name}'."
  end
end
      

Perl

# Issue a mutate request to apply the recommendations.
my $apply_recommendation_response =
  $api_client->RecommendationService()->apply({
    customerId => $customer_id,
    operations => $apply_recommendation_operations
  });

foreach my $result (@{$apply_recommendation_response->{results}}) {
  printf "Applied recommendation with resource name: '%s'.\n",
    $result->{resourceName};
}
      

觀看下列影片瞭解詳情

套用參數

大量

錯誤

測試命名空間

關閉建議

影片:關閉推薦內容

您可以使用 RecommendationService 關閉建議。程式碼結構與套用建議類似,但您需要使用 DismissRecommendationOperationRecommendationService.DismissRecommendation

觀看下列影片瞭解詳情

大量

錯誤

測試命名空間

自動套用建議

從 Google Ads API v15 版開始,您可以使用 RecommendationSubscriptionService,自動套用特定類型的建議。

如要訂閱特定推薦類型,請建立 RecommendationSubscription 物件,將 type 欄位設為其中一個支援的推薦類型,並將 status 欄位設為 ENABLED

訂閱支援的最佳化建議類型

  • ENHANCED_CPC_OPT_IN
  • KEYWORD
  • KEYWORD_MATCH_TYPE
  • LOWER_TARGET_ROAS
  • MAXIMIZE_CLICKS_OPT_IN
  • OPTIMIZE_AD_ROTATION
  • RAISE_TARGET_CPA
  • RESPONSIVE_SEARCH_AD
  • RESPONSIVE_SEARCH_AD_IMPROVE_AD_STRENGTH
  • SEARCH_PARTNERS_OPT_IN
  • SEARCH_PLUS_OPT_IN
  • SET_TARGET_CPA
  • SET_TARGET_ROAS
  • TARGET_CPA_OPT_IN
  • TARGET_ROAS_OPT_IN
  • USE_BROAD_MATCH_KEYWORD

擷取訂閱項目

如要取得帳戶建議訂閱的相關資訊,請查詢 recommendation_subscription 資源。

如要查看自動套用的變更,請查詢 change_event 資源,將 change_client_type 篩選為 GOOGLE_ADS_RECOMMENDATIONS_SUBSCRIPTION

廣告活動建立作業中的最佳化建議

從 Google Ads API v16 開始,您可以使用 RecommendationService.GenerateRecommendationsRequest,在廣告活動建構期間針對一組特定建議類型產生建議。

GenerateRecommendations 接受輸入客戶 ID,廣告管道類型必須是 SEARCHPERFORMANCE_MAX (要產生的建議類型清單),以及與指定類型相關的各種資料點。此工具會根據您提供的資料輸出 Recommendation 物件清單。如果資料不足,無法針對要求的 recommendation_types 產生建議,或廣告活動已經處於建議狀態,結果集就不會包含該類型的建議。確保應用程式處理未針對要求的推薦類型傳回建議的情況。

下表說明 GenerateRecommendations 支援的建議類型,以及您必須提供的欄位,才能接收該類型建議。最佳做法是在系統收集所有與要求推薦類型相關的資訊之後,再傳送 GenerateRecommendations 要求。如要進一步瞭解必填和選填欄位 (包括巢狀欄位),請參閱參考說明文件

RecommendationType 必填欄位 選填欄位
KEYWORD
  • seed_info
  • ad_group_info
MAXIMIZE_CLICKS_OPT_IN
  • conversion_tracking_status
  • bidding_info
MAXIMIZE_CONVERSIONS_OPT_IN
  • conversion_tracking_status
  • bidding_info
MAXIMIZE_CONVERSION_VALUE_OPT_IN
  • conversion_tracking_status
  • bidding_info
SET_TARGET_CPA
  • conversion_tracking_status
  • bidding_info
SET_TARGET_ROAS
  • conversion_tracking_status
  • bidding_info
SITELINK_ASSET
注意:傳回的 SitelinkAssetRecommendation 物件會包含空白清單。如果 GenerateRecommendations 回應包含 SitelinkAssetRecommendation,可以將此回應視為信號,為廣告活動至少新增一項網站連結素材資源。
  • campaign_sitelink_count
TARGET_CPA_OPT_IN
  • conversion_tracking_status
  • bidding_info
TARGET_ROAS_OPT_IN
  • conversion_tracking_status
  • bidding_info

使用流程範例

假設您是廣告代理商,他們為使用者提供廣告活動建構工作流程,而您想要在該流程中向使用者提供建議。您可以使用 GenerateRecommendationsRequest 依需求產生建議,並將這些建議加入廣告活動建構使用者介面。

使用流程可能如下所示:

  1. 使用者前往您的應用程式來建立最高成效廣告活動。

  2. 使用者在廣告活動建立流程中提供一些初始資訊。舉例來說,他們提供詳細資訊建構一個 SitelinkAsset,並選取 TARGET_SPEND 做為智慧出價策略。

  3. 您傳送的是 GenerateRecommendationsRequest,用來設定下列欄位:

    • campaign_sitelink_count:設為 1,這是進行中廣告活動中的網站連結素材資源數量。

    • bidding_info:將巢狀 bidding_strategy_type 欄位設為 TARGET_SPEND

    • conversion_tracking_status:設為這位客戶的 ConversionTrackingStatus。如需擷取這個欄位的指南,請參閱轉換管理入門指南

    • recommendation_types:設為 [SITELINK_ASSET, MAXIMIZE_CLICKS_OPT_IN]

    • advertising_channel_type:設為 PERFORMANCE_MAX

    • customer_id:設為建立廣告活動的客戶 ID。

  4. 您可以在 GenerateRecommendationsResponse 中採用這些建議 (在本例中為 SitelinkAssetRecommendationMaximizeClicksOptInRecommendation),並在廣告活動建構介面中顯示這些建議給使用者。如果使用者接受建議,您就可以在使用者完成廣告活動建構流程後,將建議納入廣告活動建立要求。