轉換管理

在 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)、驗證轉換追蹤功能是否有效、設定使用者同意聲明,並建立 ConversionAction,指定 ConversionActionType 和 ConversionActionCategory。
  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}".'
    )
      

小茹

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,請將 POST 要求傳送至 ConversionActionService.MutateConversionActions:

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. 匯入轉換事件

  • 匯入離線點擊轉換:上傳離線轉換 (GCLID、GBRAID、WBRAID) 和待開發客戶強化轉換 (第一方雜湊電子郵件和電話號碼),評估實際交易。
  • 匯入線上點擊轉換:使用網站強化轉換 (ENHANCEMENT 調整項),以第一方使用者資料 (例如電子郵件地址、姓名、住家地址和電話號碼) 補充網站轉換代碼。
  • 匯入來電轉換:上傳透過 Google 轉接號碼或您自己的通話追蹤系統追蹤的來電轉換事件。
  • 匯入商店銷售轉換:使用 OfflineUserDataJobService 批次上傳商店交易資料。

3. 調整及最佳化轉換

4. 監控、回報及疑難排解