最佳化分數和最佳化建議

影片:深入解析

最佳化建議可透過以下幾種方式改善廣告活動:

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

如要提高最佳化分數,您可以使用 RecommendationService 擷取最佳化建議,然後視情況套用或關閉這些建議。您也可以使用 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_DEMAND_GEN_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_ASSET 在廣告活動中加入待開發客戶表單素材資源
CALLOUT_ASSET 在廣告活動或客戶層級新增摘要素材資源
SITELINK_ASSET 在廣告活動或客戶層級新增網站連結素材資源
CALL_ASSET 在廣告活動或客戶層級新增電話素材資源
SHOPPING_ADD_AGE_GROUP 為因缺少年齡層而降級的商品新增年齡層屬性
SHOPPING_ADD_COLOR 為因缺少顏色而降級的商品新增顏色
SHOPPING_ADD_GENDER 為因缺少性別而降級的產品新增性別
SHOPPING_ADD_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 代碼
KEYWORD_MATCH_TYPE (已淘汰) 已淘汰,請改用 USE_BROAD_MATCH_KEYWORD

觀看這部影片瞭解詳情

處理不支援的類型

擷取推薦內容

影片:即時編碼

與 Google Ads API 中的大多數其他實體一樣,您可以使用 Google Ads 查詢語言查詢搭配 GoogleAdsService.SearchStream,擷取 Recommendation 物件

每種最佳化建議都會在專屬欄位中提供詳細資料。舉例來說,CAMPAIGN_BUDGET 推薦詳細資料位於 campaign_budget_recommendation 欄位中,並且會包裝在 CampaignBudgetRecommendation 物件中。

recommendation 聯集欄位中找出所有推薦專屬欄位。

建議影響

部分最佳化建議類型會填入最佳化建議的 impact 欄位。RecommendationImpact 包含採用最佳化建議後,對帳戶成效的預估影響。impact.base_metricsimpact.potential_metrics 欄位提供下列推薦指標

  • impressions

  • clicks

  • cost_micros

  • conversions

  • all_conversions

  • 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.V18.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 可能會在擷取建議後失效。

建議您在擷取後立即採取行動。

套用最佳化建議

影片:套用最佳化建議

您可以使用 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
      

小茹

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::V18::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::V18::Resources::Ad->new({
  #   id => "INSERT_AD_ID_AS_INTEGER_HERE"
  # });
  # my $text_ad_parameters =
  #   Google::Ads::GoogleAds::V18::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::V18::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.V18.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 關閉最佳化建議。程式碼結構類似於套用最佳化建議,但您會使用 DismissRecommendationOperationRecommendationService.DismissRecommendation

觀看以下影片瞭解詳情

大量

錯誤

測試命名空間

自動套用建議

您可以使用 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_event.client_type 篩選為 GOOGLE_ADS_RECOMMENDATIONS_SUBSCRIPTION

建立廣告活動時的最佳化建議

您可以使用 RecommendationService.GenerateRecommendationsRequest 在建立廣告活動時,針對特定一組最佳化建議類型產生最佳化建議。

GenerateRecommendations 會接受客戶 ID、廣告管道類型 (必須為 SEARCHPERFORMANCE_MAX)、要產生的推薦類型清單,以及取決於指定類型的各種資料點做為輸入內容。這個函式會根據您提供的資料輸出 Recommendation 物件清單。如果資料不足以產生所要求的 recommendation_types 最佳化建議,或是廣告活動已處於建議狀態,則結果集不會包含該類型的最佳化建議。請確認應用程式可處理針對要求的推薦類型,沒有傳回任何推薦內容的情況。

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

RecommendationType 必填欄位 選填欄位
CAMPAIGN_BUDGET (自 v18 起) 搜尋和最高成效廣告活動都需要下列欄位:
  • final_url
  • bidding_strategy_type
如果是搜尋廣告活動,則還必須填入下列欄位:
  • country_code
  • language_code
  • positive_location_idnegative_location_id
  • ad_group_info.keywords
  • bidding_info.
    bidding_strategy_target_info.
    target_impression_share_info
    (如果出價策略設為 TARGET_IMPRESSION_SHARE)
  • asset_group_info
  • budget_info
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),並在廣告活動建構介面中顯示這些最佳化建議,向使用者提供建議。如果使用者接受建議,您可以在使用者完成廣告活動建構流程後,將建議納入廣告活動建立要求。