最佳化分數和最佳化建議

影片:深入探索

建議可改善成效 來建立廣告活動:

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

如要提高最佳化分數,您可以使用 擷取 RecommendationService 以擷取 再據此套用或略過這些建議自第 15 版起 Google Ads API 的指示,您也可以訂閱自動套用 透過 RecommendationSubscriptionService 獲得建議。

最佳化分數

影片:最佳化分數

最佳化分數是一種 Google Ads 帳戶的預期成效 的CustomerCampaign 等級。

Customer.optimization_score_weight敬上 只適用於非管理員帳戶,且會用來計算 為多個帳戶設定最佳化分數。擷取最佳化分數並 各個帳戶的最佳化分數權重相乘 (Customer.optimization_score * Customer.optimization_score_weight) 需要運算 整體最佳化分數

customercampaign有最佳化相關指標可以使用 報告:

  1. metrics.optimization_score_url敬上 提供帳戶的深層連結,以便查看 Google Ads 使用者介面中顯示的建議。
  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 中大多數其他實體一樣,Recommendation 物件的 GoogleAdsService.SearchStream。 所對應的 Google Ads 查詢語言

每一種建議都會在 建議專用欄位例如 CAMPAIGN_BUDGET 項建議 請參閱 campaign_budget_recommendation 欄位,因此會納入在 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.V17.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)
    )
      

小茹

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 可以 而是在擷取建議後過時。

建議您在擷取後立即根據最佳化建議採取行動。

套用最佳化建議

影片:套用最佳化建議

您可以套用有效或已關閉的建議, ApplyRecommendation敬上 方法 RecommendationService

推薦類型可以包含必要或選用參數。大多數 根據預設,建議中提供的建議值。

無法設定自動套用最佳化建議的帳戶 。不過,您可以實作 Google Ads API 完整支援的建議類型行為。 請參閱 DetectAndApplyRecommendations 程式碼 範例

使用 apply_parameters敬上 ApplyRecommendationOperation 的聯集欄位,以便套用最佳化建議 特定的參數值每種適合推薦類型都有專屬欄位, 「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
      

小茹

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::V17::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::V17::Resources::Ad->new({
  #   id => "INSERT_AD_ID_AS_INTEGER_HERE"
  # });
  # my $text_ad_parameters =
  #   Google::Ads::GoogleAds::V17::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::V17::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.V17.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}'."
        )
      

小茹

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。程式碼 與套用最佳化建議類似,差別在於您需要 DismissRecommendationOperation敬上 和 RecommendationService.DismissRecommendation

觀看下列影片瞭解詳情

大量

錯誤

測試命名空間

自動套用建議

從 Google Ads API v15 開始,您可以使用 RecommendationSubscriptionService敬上 自動套用特定類型的最佳化建議

如要訂閱特定推薦類型,請建立 RecommendationSubscription 物件, 將 type 欄位設為 支援的建議 types,然後將 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敬上 - 在這個範例中 SitelinkAssetRecommendation。 和 MaximizeClicksOptInRecommendation — 在廣告活動中顯示這些使用者,向他們建議 建構介面如果使用者接受建議,您可以 等使用者完成建立流程後 建立廣告活動的流程