优化得分和建议

视频:深入探究

建议可通过以下几种方式提升广告系列的效果:

  • 推出相关的新功能
  • 通过改进出价、关键字和广告,获得更高的投入回报
  • 提高广告系列的整体效果和效率

如需提高优化得分,您可以使用 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_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 而被降级的商品添加 GTIN(全球贸易项目代码)
SHOPPING_ADD_MORE_IDENTIFIERS 为因缺少标识码而降位的商品添加更多标识码
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 建议详细信息位于 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)
    )
      

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::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}'."
        )
      

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

观看这些视频,了解详情

批量

错误

测试

自动采纳建议

您可以使用 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)中的推荐,并通过在广告系列构建界面中显示来向用户推荐这些推荐。如果用户接受了建议,您可以在用户完成广告系列制作流程后,将建议合并到广告系列制作请求中。