Tạo tiêu chí loại trừ dữ liệu

Tiêu chí loại trừ dữ liệu là một công cụ nâng cao mà bạn có thể dùng để cho chiến lược Đặt giá thầu thông minh biết khi cần bỏ qua tất cả dữ liệu vào những ngày tính năng theo dõi lượt chuyển đổi của một tài khoản gặp vấn đề. Để biết thêm thông tin chi tiết về cách hoạt động của tiêu chí loại trừ dữ liệu, hãy tham khảo trang trợ giúp về tiêu chí loại trừ dữ liệu.

Bạn có thể tạo, cập nhật hoặc xoá tiêu chí loại trừ dữ liệu theo phương thức lập trình bằng cách sử dụng tài nguyên BiddingDataExclusion và BiddingDataExclusionService.MutateBiddingDataExclusions với BiddingDataExclusionOperation (create, update, hoặc remove; lưu ý rằng BiddingDataExclusion.status là chỉ đọc/OUTPUT_ONLY). Bạn không thể tạo BiddingDataExclusion trong tài khoản người quản lý; bạn phải tạo tiêu chí này trong tài khoản khách hàng của khách hàng có phạm vi là CAMPAIGN hoặc CHANNEL.

Phạm vi

Một BiddingDataExclusion có scope bắt buộc mà bạn có thể đặt thành các giá trị sau. Bạn có thể đặt các tuỳ chọn cấu hình bổ sung theo phạm vi tuỳ thuộc vào phạm vi được sử dụng.

  • CAMPAIGN: Tiêu chí loại trừ này được áp dụng cho các chiến dịch cụ thể. Đặt trường campaigns thành danh sách tên tài nguyên chiến dịch mà tiêu chí loại trừ này sẽ áp dụng.
  • CHANNEL: Tiêu chí loại trừ này được áp dụng cho các chiến dịch thuộc các loại kênh cụ thể. Đặt trường advertising_channel_types thành danh sách các giá trị AdvertisingChannelType mà tiêu chí loại trừ này sẽ áp dụng.

Thiết bị

Ngoài phạm vi, bạn có thể định cấu hình tiêu chí loại trừ dữ liệu bằng danh sách không bắt buộc gồm các loại thiết bị mà tiêu chí loại trừ này sẽ áp dụng. Nếu devices được đặt, thì hệ thống sẽ chỉ loại trừ dữ liệu lượt chuyển đổi từ các loại thiết bị được chỉ định. Nếu bạn không chỉ định, thì hệ thống sẽ loại trừ dữ liệu lượt chuyển đổi từ tất cả các loại thiết bị.

Ngày và giờ

Ngoài phạm vi và các thiết bị không bắt buộc, mỗi tiêu chí loại trừ dữ liệu phải có ngày và giờ bắt đầu và kết thúc được định dạng là yyyy-MM-dd HH:mm:ss. Tiêu chí loại trừ dữ liệu có hiệu lực ngược về quá khứ và bạn nên sử dụng tiêu chí này cho các sự kiện có start_date_time trong quá khứ và end_date_time trong quá khứ hoặc tương lai. Thời gian được tính theo múi giờ của tài khoản.

Giới hạn

Khi làm việc với tài nguyên BiddingDataExclusion, hãy lưu ý các giới hạn sau:

  • Một BiddingDataExclusion có thể áp dụng cho tối đa 2.000 chiến dịch khi phạm vi được đặt thành CAMPAIGN.
  • Mỗi tài khoản khách hàng (bao gồm cả tài khoản người quản lý và tài khoản thử nghiệm) có thể có tối đa 500 tiêu chí loại trừ dữ liệu giá thầu đang hoạt động tại bất kỳ thời điểm nào. Nếu vượt quá giới hạn này, bạn sẽ gặp lỗi RESOURCE_LIMIT.

Ví dụ

Ví dụ sau đây cho thấy cách tạo tiêu chí loại trừ dữ liệu có phạm vi CHANNEL. Các phần được đánh dấu là nội dung nhận xét minh hoạ cách chỉ định chiến dịch nếu bạn đặt phạm vi 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
);
      

Python

bidding_data_exclusion_service: BiddingDataExclusionServiceClient = (
    client.get_service("BiddingDataExclusionService")
)
operation: BiddingDataExclusionOperation = client.get_type(
    "BiddingDataExclusionOperation"
)
bidding_data_exclusion: BiddingDataExclusion = operation.create
# A unique name is required for every data exclusion
bidding_data_exclusion.name = f"Data exclusion #{uuid4()}"
# 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.
bidding_data_exclusion.scope = (
    client.enums.SeasonalityEventScopeEnum.CHANNEL
)
bidding_data_exclusion.advertising_channel_types.append(
    client.enums.AdvertisingChannelTypeEnum.SEARCH
)
# If setting scope CAMPAIGN, add individual campaign resource name(s)
# according to the commented out line below.
#
# bidding_data_exclusion.campaigns.append(
#     "INSERT_CAMPAIGN_RESOURCE_NAME_HERE"
# )

bidding_data_exclusion.start_date_time = start_date_time
bidding_data_exclusion.end_date_time = end_date_time

response: MutateBiddingDataExclusionsResponse = (
    bidding_data_exclusion_service.mutate_bidding_data_exclusions(
        customer_id=customer_id, operations=[operation]
    )
)

resource_name: str = response.results[0].resource_name

print(f"Added data exclusion with resource name: '{resource_name}'")
      

Ruby

client = Google::Ads::GoogleAds::GoogleAdsClient.new

operation = client.operation.create_resource.bidding_data_exclusion do |bda|
  # A unique name is required for every data excluseion.
  bda.name = "Seasonality Adjustment #{(Time.new.to_f * 1000).to_i}"

  # The CHANNEL scope applies the data exclusion to all campaigns of specific
  # advertising channel types. In this example, the conversion_rate_modifier
  # will only apply to Search campaigns. Use the CAMPAIGN scope to instead
  # limit the scope to specific campaigns.
  bda.scope = :CHANNEL
  bda.advertising_channel_types << :SEARCH

  # If setting scope CAMPAIGN, add individual campaign resource name(s)
  # according to the commented out line below.
  #
  # bda.campaigns << "INSERT_CAMPAIGN_RESOURCE_NAME_HERE"

  bda.start_date_time = start_date_time
  bda.end_date_time = end_date_time
end

response = client.service.bidding_data_exclusion.mutate_bidding_data_exclusions(
  customer_id: customer_id,
  operations: [operation],
)

puts "Added data exclusion with resource name #{response.results.first.resource_name}."
      

Perl

my $data_exclusion =
  Google::Ads::GoogleAds::V26::Resources::BiddingDataExclusion->new({
    # A unique name is required for every data exclusion.
    name => "Data exclusion #" . uniqid(),
    # 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                   => CHANNEL,
    advertisingChannelTypes => [SEARCH],
    # If setting scope CAMPAIGN, add individual campaign resource name(s)
    # according to the commented out line below.
    # campaigns     => ["INSERT_CAMPAIGN_RESOURCE_NAME_HERE"],
    startDateTime => $start_date_time,
    endDateTime   => $end_date_time
  });

my $operation =
  Google::Ads::GoogleAds::V26::Services::BiddingDataExclusionService::BiddingDataExclusionOperation
  ->new({
    create => $data_exclusion
  });

my $response = $api_client->BiddingDataExclusionService()->mutate({
    customerId => $customer_id,
    operations => [$operation]});

printf "Added data exclusion with resource name: '%s'.\n",
  $response->{results}[0]{resourceName};
      

curl