转化管理

在 Google Ads 中,转化是指用户在与广告互动后执行的有价值的操作,例如购买产品、提交潜在客户表单、致电您的商家或光顾实体店。转化跟踪可衡量这些客户互动,以便您评估广告系列效果并优化自动出价。

借助 Google Ads API,您可以通过编程方式配置转化操作、导入线下转化事件、增强或调整记录的转化、将操作分组到出价和生命周期目标中,以及监控上传诊断。

选择转换工作流

请参考下表,根据您的使用场景确定 ConversionActionType、API 服务和实现指南:

任务 转化操作类型 API 服务或资源 实施指南
验证账号设置并创建转化操作 UPLOAD_CLICKS、WEBPAGE、UPLOAD_CALLS、AD_CALL、WEBSITE_CALL、GOOGLE_PLAY_DOWNLOAD、GOOGLE_PLAY_IN_APP_PURCHASE Customer (ConversionTrackingSetting), ConversionActionService 开始和转化操作类别
导入线下点击转化数据或增强型潜在客户转化数据 UPLOAD_CLICKS ConversionUploadService.UploadClickConversions(或 Data Manager API,适用于新集成) 导入线下点击转化数据
增强型线上转化(增强型网站转化) WEBPAGE ConversionAdjustmentUploadService.UploadConversionAdjustments (ENHANCEMENT) 导入线上点击转化数据
导入致电转化数据 UPLOAD_CALLS ConversionUploadService.UploadCallConversions 导入来电转化数据
导入实体店销售交易数据 STORE_SALES、STORE_SALES_DIRECT_UPLOAD OfflineUserDataJobService(或 Data Manager API) 导入实体店销售转化数据
撤消或重报记录的转化 UPLOAD_CLICKS、WEBPAGE、SALESFORCE(已弃用) ConversionAdjustmentUploadService.UploadConversionAdjustments (RETRACTION、RESTATEMENT) 在导入后调整转化数据
将自定义代码元数据附加到转化 UPLOAD_CLICKS、UPLOAD_CALLS、WEBPAGE ConversionCustomVariableService 自定义转化变量
配置出价目标、生命周期目标和价值规则 账号、广告系列和生命周期目标 CustomerConversionGoalService、CampaignConversionGoalService、CustomConversionGoalService、ConversionGoalCampaignConfigService、GoalService、CampaignGoalConfigService、ConversionValueRuleService 转化目标、生命周期目标和转化价值规则
监控导入运行状况和错误诊断 UPLOAD_CLICKS、WEBPAGE、UPLOAD_CALLS offline_conversion_upload_client_summary、offline_conversion_upload_conversion_action_summary 监控线下数据诊断
查询转化指标并排查错误 所有转化类型 GoogleAdsService.SearchStream (customer, campaign, conversion_action) 提取转化统计信息和排查转化数据导入问题

端到端转化生命周期

Google Ads API 中的完整转化管理集成遵循以下四个阶段:

  1. 验证账号设置并创建转化操作:查询 Customer.conversion_tracking_setting 以确认有效的转化账号 (google_ads_conversion_customer),验证转化跟踪是否处于有效状态,配置用户同意,并使用目标 ConversionActionType 和 ConversionActionCategory 创建 ConversionAction。
  2. 导入转化事件:使用 ConversionUploadService(partial_failure 设置为 true)流式传输线下点击或来电转化,使用 ConversionAdjustmentUploadService 通过 ENHANCEMENT 调整来补充网站转化,或使用 OfflineUserDataJobService 批量上传实体店销售。
  3. 调整和优化转化:使用 ConversionAdjustmentUploadService 撤消或重报记录的转化,附加 ConversionCustomVariable 元数据,应用转化价值规则,并将操作整理到转化目标和生命周期目标中,以控制出价优化。
  4. 监控诊断信息和报告效果:查询 offline_conversion_upload_client_summary 和 offline_conversion_upload_conversion_action_summary,以检查上传处理状态和部分失败提醒。查询 customer 或 campaign 资源(可选择按 segments.conversion_action 进行细分),以比较 metrics.conversions 和 metrics.all_conversions 指标,或查询 conversion_action 资源,以检查 metrics.all_conversions 和上次转化时间戳。

快速入门:验证设置、创建操作和检查健康状况

以下示例展示了初始化和监控转化跟踪所需的三种最常见的查询和变更。

1. 使用 GAQL 验证转化跟踪设置

在创建 ConversionAction 或上传事件之前,请使用 GoogleAdsService.SearchStream 查询 customer 资源,以确定哪个账号管理转化 (google_ads_conversion_customer)、是否接受了客户数据条款,以及是否启用了账号级增强型转化 (EnhancedConversionsConfig):

SELECT
  customer.conversion_tracking_setting.conversion_tracking_id,
  customer.conversion_tracking_setting.conversion_tracking_status,
  customer.conversion_tracking_setting.cross_account_conversion_tracking_id,
  customer.conversion_tracking_setting.google_ads_conversion_customer,
  customer.conversion_tracking_setting.accepted_customer_data_terms,
  customer.conversion_tracking_setting.enablement_setting,
  customer.conversion_tracking_setting.effective_enablement_setting
FROM customer

从 google_ads_conversion_customer 中返回的 customers/{customer_id} 资源名称中提取 {customer_id},并针对该客户 ID 发出所有后续 ConversionActionService 和 ConversionUploadService 请求。如需了解完整的设置和跨账号层次结构详情,请参阅使用入门。

2. 创建转化操作

使用 ConversionActionService.MutateConversionActions 创建 ConversionAction。以下示例创建了一个具有自定义价值和回溯期设置的 UPLOAD_CLICKS 转化操作:

Java

private void runExample(GoogleAdsClient googleAdsClient, long customerId) {

  // Creates a ConversionAction.
  ConversionAction conversionAction =
      ConversionAction.newBuilder()
          // Note that conversion action names must be unique. If a conversion action already
          // exists with the specified conversion_action_name the create operation will fail with
          // a ConversionActionError.DUPLICATE_NAME error.
          .setName("Earth to Mars Cruises Conversion #" + getPrintableDateTime())
          .setCategory(ConversionActionCategory.DEFAULT)
          .setType(ConversionActionType.WEBPAGE)
          .setStatus(ConversionActionStatus.ENABLED)
          .setViewThroughLookbackWindowDays(15L)
          .setValueSettings(
              ValueSettings.newBuilder()
                  .setDefaultValue(23.41)
                  .setAlwaysUseDefaultValue(true)
                  .build())
          .build();

  // Creates the operation.
  ConversionActionOperation operation =
      ConversionActionOperation.newBuilder().setCreate(conversionAction).build();

  try (ConversionActionServiceClient conversionActionServiceClient =
      googleAdsClient.getLatestVersion().createConversionActionServiceClient()) {
    MutateConversionActionsResponse response =
        conversionActionServiceClient.mutateConversionActions(
            Long.toString(customerId), Collections.singletonList(operation));
    System.out.printf("Added %d conversion actions:%n", response.getResultsCount());
    for (MutateConversionActionResult result : response.getResultsList()) {
      System.out.printf(
          "New conversion action added with resource name: '%s'%n", result.getResourceName());
    }
  }
}
      

C#

public void Run(GoogleAdsClient client, long customerId)
{
    // Get the ConversionActionService.
    ConversionActionServiceClient conversionActionService =
        client.GetService(Services.V26.ConversionActionService);

    // Note that conversion action names must be unique.
    // If a conversion action already exists with the specified name the create operation
    // will fail with a ConversionAction.DUPLICATE_NAME error.
    string ConversionActionName = "Earth to Mars Cruises Conversion #"
        + ExampleUtilities.GetRandomString();

    // Add a conversion action.
    ConversionAction conversionAction = new ConversionAction()
    {
        Name = ConversionActionName,
        Category = ConversionActionCategory.Default,
        Type = ConversionActionType.Webpage,
        Status = ConversionActionStatus.Enabled,
        ViewThroughLookbackWindowDays = 15,
        ValueSettings = new ConversionAction.Types.ValueSettings()
        {
            DefaultValue = 23.41,
            AlwaysUseDefaultValue = true
        }
    };

    // Create the operation.
    ConversionActionOperation operation = new ConversionActionOperation()
    {
        Create = conversionAction
    };

    try
    {
        // Create the conversion action.
        MutateConversionActionsResponse response =
            conversionActionService.MutateConversionActions(customerId.ToString(),
                    new ConversionActionOperation[] { operation });

        // Display the results.
        foreach (MutateConversionActionResult newConversionAction in response.Results)
        {
            Console.WriteLine($"New conversion action with resource name = " +
                $"'{newConversionAction.ResourceName}' was added.");
        }
    }
    catch (GoogleAdsException e)
    {
        Console.WriteLine("Failure:");
        Console.WriteLine($"Message: {e.Message}");
        Console.WriteLine($"Failure: {e.Failure}");
        Console.WriteLine($"Request ID: {e.RequestId}");
        throw;
    }
}
      

PHP

    public static function runExample(GoogleAdsClient $googleAdsClient, int $customerId)
    {
        // Creates a conversion action.
        $conversionAction = new ConversionAction(
            [
            // Note that conversion action names must be unique.
            // If a conversion action already exists with the specified conversion_action_name
            // the create operation will fail with a ConversionActionError.DUPLICATE_NAME error.
            'name' => 'Earth to Mars Cruises Conversion #' . Helper::getPrintableDatetime(),
            'category' => ConversionActionCategory::PBDEFAULT,
            'type' => ConversionActionType::WEBPAGE,
            'status' => ConversionActionStatus::ENABLED,
            'view_through_lookback_window_days' => 15,
            'value_settings' => new ValueSettings(
                [
                'default_value' => 23.41,
                'always_use_default_value' => true
                ]
            )
            ]
        );

        // Creates a conversion action operation.
        $conversionActionOperation = new ConversionActionOperation();
        $conversionActionOperation->setCreate($conversionAction);

        // Issues a mutate request to add the conversion action.
        $conversionActionServiceClient = $googleAdsClient->getConversionActionServiceClient();
        $response = $conversionActionServiceClient->mutateConversionActions(
            MutateConversionActionsRequest::build($customerId, [$conversionActionOperation])
        );

        printf("Added %d conversion actions:%s", $response->getResults()->count(), PHP_EOL);

        foreach ($response->getResults() as $addedConversionAction) {
            /**
 * @var ConversionAction $addedConversionAction
*/
            printf(
                "New conversion action added with resource name: '%s'%s",
                $addedConversionAction->getResourceName(),
                PHP_EOL
            );
        }
    }
      

Python

def main(client: GoogleAdsClient, customer_id: str) -> None:
    conversion_action_service: ConversionActionServiceClient = (
        client.get_service("ConversionActionService")
    )

    # Create the operation.
    conversion_action_operation: ConversionActionOperation = client.get_type(
        "ConversionActionOperation"
    )

    # Create conversion action.
    conversion_action: ConversionAction = conversion_action_operation.create

    # Note that conversion action names must be unique. If a conversion action
    # already exists with the specified conversion_action_name, the create
    # operation will fail with a ConversionActionError.DUPLICATE_NAME error.
    conversion_action.name = f"Earth to Mars Cruises Conversion {uuid.uuid4()}"
    conversion_action.type_ = (
        client.enums.ConversionActionTypeEnum.UPLOAD_CLICKS
    )
    conversion_action.category = (
        client.enums.ConversionActionCategoryEnum.DEFAULT
    )
    conversion_action.status = client.enums.ConversionActionStatusEnum.ENABLED
    conversion_action.view_through_lookback_window_days = 15

    # Create a value settings object.
    value_settings: ConversionAction.ValueSettings = (
        conversion_action.value_settings
    )
    value_settings.default_value = 15.0
    value_settings.always_use_default_value = True

    # Add the conversion action.
    conversion_action_response: MutateConversionActionsResponse = (
        conversion_action_service.mutate_conversion_actions(
            customer_id=customer_id,
            operations=[conversion_action_operation],
        )
    )

    print(
        "Created conversion action "
        f'"{conversion_action_response.results[0].resource_name}".'
    )
      

Ruby

def add_conversion_action(customer_id)
  # GoogleAdsClient will read a config file from
  # ENV['HOME']/google_ads_config.rb when called without parameters
  client = Google::Ads::GoogleAds::GoogleAdsClient.new


  # Add a conversion action.
  conversion_action = client.resource.conversion_action do |ca|
    ca.name = "Earth to Mars Cruises Conversion #{(Time.new.to_f * 100).to_i}"
    ca.type = :UPLOAD_CLICKS
    ca.category = :DEFAULT
    ca.status = :ENABLED
    ca.view_through_lookback_window_days = 15

    # Create a value settings object.
    ca.value_settings = client.resource.value_settings do |vs|
      vs.default_value = 15
      vs.always_use_default_value = true
    end
  end

  # Create the operation.
  conversion_action_operation = client.operation.create_resource.conversion_action(conversion_action)

  # Add the ad group ad.
  response = client.service.conversion_action.mutate_conversion_actions(
    customer_id: customer_id,
    operations: [conversion_action_operation],
  )

  puts "New conversion action with resource name = #{response.results.first.resource_name}."
end
      

Perl

sub add_conversion_action {
  my ($api_client, $customer_id) = @_;

  # Note that conversion action names must be unique.
  # If a conversion action already exists with the specified conversion_action_name,
  # the create operation fails with error ConversionActionError.DUPLICATE_NAME.
  my $conversion_action_name = "Earth to Mars Cruises Conversion #" . uniqid();

  # Create a conversion action.
  my $conversion_action =
    Google::Ads::GoogleAds::V26::Resources::ConversionAction->new({
      name                          => $conversion_action_name,
      category                      => DEFAULT,
      type                          => WEBPAGE,
      status                        => ENABLED,
      viewThroughLookbackWindowDays => 15,
      valueSettings                 =>
        Google::Ads::GoogleAds::V26::Resources::ValueSettings->new({
          defaultValue          => 23.41,
          alwaysUseDefaultValue => "true"
        })});

  # Create a conversion action operation.
  my $conversion_action_operation =
    Google::Ads::GoogleAds::V26::Services::ConversionActionService::ConversionActionOperation
    ->new({create => $conversion_action});

  # Add the conversion action.
  my $conversion_actions_response =
    $api_client->ConversionActionService()->mutate({
      customerId => $customer_id,
      operations => [$conversion_action_operation]});

  printf "New conversion action added with resource name: '%s'.\n",
    $conversion_actions_response->{results}[0]{resourceName};

  return 1;
}
      

curl

REST 请求

如需通过 REST 创建相同的 ConversionAction,请向 ConversionActionService.MutateConversionActions 发送 POST 请求:

POST https://googleads.googleapis.com/v26/customers/{customer_id}/conversionActions:mutate
{
  "operations": [
    {
      "create": {
        "name": "Earth to Mars Cruise Conversion",
        "type": "UPLOAD_CLICKS",
        "category": "DEFAULT",
        "status": "ENABLED",
        "primaryForGoal": true,
        "countingType": "ONE_PER_CLICK",
        "clickThroughLookbackWindowDays": "60",
        "valueSettings": {
          "defaultValue": 23.41,
          "defaultCurrencyCode": "USD",
          "alwaysUseDefaultValue": true
        }
      }
    }
  ]
}

转化操作 ENABLED 后,请使用转化来源的工作流导入转化事件或增强功能(请参阅导入转化事件)。

3. 监控线下转化数据上传运行状况

上传点击转化、来电转化或转化调整后,查询 offline_conversion_upload_client_summary 以查看近期上传的总体作业状态、成功率和待处理率,以及错误明细:

SELECT
  offline_conversion_upload_client_summary.client,
  offline_conversion_upload_client_summary.status,
  offline_conversion_upload_client_summary.total_event_count,
  offline_conversion_upload_client_summary.successful_event_count,
  offline_conversion_upload_client_summary.success_rate,
  offline_conversion_upload_client_summary.pending_event_count,
  offline_conversion_upload_client_summary.pending_rate,
  offline_conversion_upload_client_summary.last_upload_date_time,
  offline_conversion_upload_client_summary.alerts
FROM offline_conversion_upload_client_summary

查询 offline_conversion_upload_conversion_action_summary 以获取转化操作级诊断信息(请参阅监控线下数据诊断),并参阅排查转化数据导入问题以解决特定错误代码。

按生命周期阶段划分的指南目录

探索按生命周期阶段整理的完整转化管理指南:

1. 账号开设和转化操作

  • 转化操作类别:选择正确的转化来源,即网站 (WEBPAGE)、来电 (UPLOAD_CALLS、AD_CALL、WEBSITE_CALL)、移动应用(GOOGLE_PLAY_DOWNLOAD、GOOGLE_PLAY_IN_APP_PURCHASE、Firebase、SKAdNetwork)、Google Analytics 4(GOOGLE_ANALYTICS_4_CUSTOM、GOOGLE_ANALYTICS_4_PURCHASE)、线下 (UPLOAD_CLICKS) 或实体店 (STORE_SALES),并将其映射到相应的 ConversionActionType 和 API 工作流。
  • 开始使用:配置用户同意、验证 ConversionTrackingSetting、设置跨账号转化跟踪,以及使用客户端库或 REST 创建转化操作。

2. 导入转化事件

3. 调整和优化转化

4. 监控、报告和问题排查