← 返回目录
来源:Google Ads API 官方文档 · 中文版 · 本地归档

创建数据排除项

数据排除是一款高级工具,可用于告知智能出价忽略账号的转化跟踪出现问题期间的所有数据。如需详细了解数据排除功能的运作方式,请参阅数据排除帮助页面。

使用 BiddingDataExclusions 以编程方式创建数据排除项。您无法在经理账号中设置 BiddingDataExclusions,只能在广告系列一级设置。

范围

BiddingDataExclusions 具有必需的 scope,可将其设置为以下值。其他特定于范围的配置选项会根据所使用的范围进行设置。

  • CAMPAIGN - 排除对象应用于特定广告系列。将 campaigns 字段设置为将应用此排除设置的广告系列资源名称列表。
    • 每个 BiddingDataExclusion 的广告系列数量上限为 2,000 个。
  • CHANNEL - 排除对象应用于属于特定渠道类型的广告系列。将 advertising_channel_types 字段设置为此排除对象将应用到的 AdvertisingChannelTypes 列表。

设备

除了范围之外,还可以配置数据排除项,并提供一个可选的设备类型列表,用于指定排除项将应用于哪些设备类型。如果设置了 devices,则仅排除指定设备类型的转化数据。如果未指定,则会排除所有设备类型的转化数据。

日期和时间

除了范围和可选设备之外,每项数据排除都必须包含开始日期和时间以及结束日期和时间。数据排除是回顾性的,应针对具有以下特征的事件使用:start_date_time 在过去,end_date_time 在过去或未来。时间以账号的时区为准。

限制

使用出价数据排除功能时,请注意以下限制:

  • 如果范围设置为 CAMPAIGN,则单个 BiddingDataExclusion 最多可应用于 2,000 个广告系列。
  • 每个客户账号(包括经理账号和测试账号)在任意指定时刻最多可以有 500 个有效的出价数据排除对象。超出此限制将导致 RESOURCE_LIMIT 错误。

示例

以下示例展示了如何创建具有 CHANNEL 范围的数据排除对象。 注释掉的部分展示了如何指定广告系列(如果您要设置 CAMPAIGN 范围)。

Java

BiddingDataExclusion DataExclusion =
    BiddingDataExclusion.newBuilder()
        // A unique name is required for every data exclusion.
        .setName("Data exclusion #" + getPrintableDateTime())
        // The CHANNEL scope applies the data exclusion to all campaigns of specific
        // advertising channel types. In this example, the exclusion will only apply to
        // Search campaigns. Use the CAMPAIGN scope to instead limit the scope to specific
        // campaigns.
        .setScope(SeasonalityEventScope.CHANNEL)
        .addAdvertisingChannelTypes(AdvertisingChannelType.SEARCH)
        // If setting scope CAMPAIGN, add individual campaign resource name(s) according to
        // the commented out line below.
        // .addCampaigns("INSERT_CAMPAIGN_RESOURCE_NAME_HERE")
        .setStartDateTime(startDateTime)
        .setEndDateTime(endDateTime)
        .build();

BiddingDataExclusionOperation operation =
    BiddingDataExclusionOperation.newBuilder().setCreate(DataExclusion).build();

MutateBiddingDataExclusionsResponse response =
    DataExclusionServiceClient.mutateBiddingDataExclusions(
        customerId.toString(), ImmutableList.of(operation));
System.out.printf(
    "Added data exclusion with resource name: %s%n",
    response.getResults(0).getResourceName());
      

C#

BiddingDataExclusion dataExclusion = new BiddingDataExclusion()
{
    // A unique name is required for every data exclusion.
    Name = "Data exclusion #" + ExampleUtilities.GetRandomString(),
    // The CHANNEL scope applies the data exclusion to all campaigns of specific
    // advertising channel types. In this example, the the exclusion will only apply to
    // Search campaigns. Use the CAMPAIGN scope to instead limit the scope to specific
    // campaigns.
    Scope = SeasonalityEventScope.Channel,
    AdvertisingChannelTypes = { AdvertisingChannelType.Search },
    // The date range should be less than 14 days.
    StartDateTime = startDateTime,
    EndDateTime = endDateTime,
};
BiddingDataExclusionOperation operation = new BiddingDataExclusionOperation()
{
    Create = dataExclusion
};

try
{
    MutateBiddingDataExclusionsResponse response =
        biddingDataExclusionService.MutateBiddingDataExclusions(
            customerId.ToString(), new[] { operation });
    Console.WriteLine($"Added data exclusion with resource name: " +
        $"{response.Results[0].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

// Creates a bidding data exclusion.
$dataExclusion = new BiddingDataExclusion([
    // A unique name is required for every data exclusion.
    'name' => 'Data exclusion #' . Helper::getPrintableDatetime(),
    // The CHANNEL scope applies the data exclusion to all campaigns of specific
    // advertising channel types. In this example, the exclusion will only apply to
    // Search campaigns. Use the CAMPAIGN scope to instead limit the scope to specific
    // campaigns.
    'scope' => SeasonalityEventScope::CHANNEL,
    'advertising_channel_types' => [AdvertisingChannelType::SEARCH],
    // If setting scope CAMPAIGN, add individual campaign resource name(s) according to
    // the commented out line below.
    // 'campaigns' => ['INSERT_CAMPAIGN_RESOURCE_NAME_HERE'],
    'start_date_time' => $startDateTime,
    'end_date_time' => $endDateTime
]);

// Creates a bidding data exclusion operation.
$biddingDataExclusionOperation = new BiddingDataExclusionOperation();
$biddingDataExclusionOperation->setCreate($dataExclusion);

// Submits the bidding data exclusion operation to add the bidding data exclusion.
$biddingDataExclusionServiceClient =
    $googleAdsClient->getBiddingDataExclusionServiceClient();
$response = $biddingDataExclusionServiceClient->mutateBiddingDataExclusions(
    MutateBiddingDataExclusionsRequest::build($customerId, [$biddingDataExclusionOperation])
);

printf(
    "Added bidding data exclusion with resource name: '%s'.%s",
    $response->getResults()[0]->getResourceName(),
    PHP_EOL
);
在接这个接口时卡住了?
Stuck wiring this API into production? We build ad-delivery tooling on these platforms — campaign automation, reporting pipelines, error-handling and migration between API versions.
联系我们 · Talk to us 每日平台更新简报 →