创建季节性调整

季节性调整是一种高级工具,可用于就即将发生的未来活动向智能出价提供与转化率预期变化有关的信息。如需详细了解季节性调整的工作原理,请参阅季节性调整帮助页面

使用 BiddingSeasonalityAdjustments 以编程方式创建季节性调整。

范围

BiddingSeasonalityAdjustments 具有必需的 scope,可设置为以下值。根据使用的范围设置额外的特定于范围的配置选项。

  • CAMPAIGN - 该调整项将应用于特定广告系列。将 campaigns 字段设置为应用此调整的广告系列资源名称列表。
    • 每个BiddingSeasonalityAdjustment可包含的广告系列数量上限为 2,000 个。
  • CHANNEL - 该调整会应用于属于特定渠道类型的广告系列。将 advertising_channel_types 字段设置为要将此调整应用到的 AdvertisingChannelTypes 的列表。

设备

除了范围之外,还可使用应用调整的设备类型列表(可选)来配置季节性调整。如果设置了 devices,季节性调整将仅应用于来自指定设备类型的流量。如果未指定,则所有设备类型都会包含在调整中。

日期、时间和转化率调节系数

除了范围和可选设备之外,每项季节性调整还有 start_date_timeend_date_timeconversion_rate_modifier。日期和时间定义要应用调整的未来时间间隔,修饰符是指要应用的预期转化率调节系数。日期时间采用帐号的时区。

示例

以下示例展示了如何创建范围为 CHANNEL 的季节性调整。注释掉部分介绍了如果您要改为设置 CAMPAIGN 范围,应如何指定广告系列。

Java

BiddingSeasonalityAdjustment seasonalityAdjustment =
    BiddingSeasonalityAdjustment.newBuilder()
        // A unique name is required for every seasonality adjustment.
        .setName("Seasonality adjustment #" + getPrintableDateTime())
        // The CHANNEL scope applies the conversionRateModifier to all campaigns of specific
        // advertising channel types. In this example, the conversionRateModifier 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)
        // The conversionRateModifier is the expected future conversion rate change. When this
        // field is unset or set to 1.0, no adjustment will be applied to traffic. The allowed
        // range is 0.1 to 10.0.
        .setConversionRateModifier(conversionRateModifier)
        .build();

BiddingSeasonalityAdjustmentOperation operation =
    BiddingSeasonalityAdjustmentOperation.newBuilder()
        .setCreate(seasonalityAdjustment)
        .build();

MutateBiddingSeasonalityAdjustmentsResponse response =
    seasonalityAdjustmentServiceClient.mutateBiddingSeasonalityAdjustments(
        customerId.toString(), ImmutableList.of(operation));
System.out.printf(
    "Added seasonality adjustment with resource name: %s%n",
    response.getResults(0).getResourceName());
      

C#

BiddingSeasonalityAdjustment seasonalityAdjustment =
    new BiddingSeasonalityAdjustment()
    {
        // A unique name is required for every seasonality adjustment.
        Name = "Seasonality adjustment #" + ExampleUtilities.GetRandomString(),
        // The CHANNEL scope applies the conversionRateModifier to all campaigns of
        // specific advertising channel types. In this example, the
        // conversionRateModifier will only apply to Search campaigns. Use the
        // CAMPAIGN scope to instead limit the scope to specific campaigns.
        Scope = SeasonalityEventScope.Channel,
        AdvertisingChannelTypes = { 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" },
        // The date range should be less than 14 days.
        StartDateTime = startDateTime,
        EndDateTime = endDateTime,
        // The conversionRateModifier is the expected future conversion rate change.
        // When this field is unset or set to 1.0, no adjustment will be applied to
        // traffic. The allowed range is 0.1 to 10.0.
        ConversionRateModifier = conversionRateModifier
    };

BiddingSeasonalityAdjustmentOperation operation =
    new BiddingSeasonalityAdjustmentOperation()
    {
        Create = seasonalityAdjustment
    };

try
{
    MutateBiddingSeasonalityAdjustmentsResponse response =
        biddingSeasonalityAdjustmentService.MutateBiddingSeasonalityAdjustments(
            customerId.ToString(), new[] { operation });
    Console.WriteLine($"Added seasonality adjustment 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 seasonality adjustment.
$seasonalityAdjustment = new BiddingSeasonalityAdjustment([
    // A unique name is required for every seasonality adjustment.
    'name' => 'Seasonality adjustment #' . Helper::getPrintableDatetime(),
    // The CHANNEL scope applies the conversionRateModifier to all campaigns of specific
    // advertising channel types. In this example, the conversionRateModifier 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,
    // The conversionRateModifier is the expected future conversion rate change. When this
    // field is unset or set to 1.0, no adjustment will be applied to traffic. The allowed
    // range is 0.1 to 10.0.
    'conversion_rate_modifier' => $conversionRateModifier
]);

// Creates a bidding seasonality adjustment operation.
$biddingSeasonalityAdjustmentOperation = new BiddingSeasonalityAdjustmentOperation();
$biddingSeasonalityAdjustmentOperation->setCreate($seasonalityAdjustment);

// Submits the bidding seasonality adjustment operation to add the bidding seasonality
// adjustment.
$biddingSeasonalityAdjustmentServiceClient =
    $googleAdsClient->getBiddingSeasonalityAdjustmentServiceClient();
$response = $biddingSeasonalityAdjustmentServiceClient->mutateBiddingSeasonalityAdjustments(
    MutateBiddingSeasonalityAdjustmentsRequest::build(
        $customerId,
        [$biddingSeasonalityAdjustmentOperation]
    )
);

printf(
    "Added seasonality adjustment with resource name: '%s'.%s",
    $response->getResults()[0]->getResourceName(),
    PHP_EOL
);
      

Python

bidding_seasonality_adjustment_service = client.get_service(
    "BiddingSeasonalityAdjustmentService"
)
operation = client.get_type("BiddingSeasonalityAdjustmentOperation")
bidding_seasonality_adjustment = operation.create
# A unique name is required for every seasonality adjustment.
bidding_seasonality_adjustment.name = f"Seasonality adjustment #{uuid4()}"
# The CHANNEL scope applies the conversion_rate_modifier 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.
bidding_seasonality_adjustment.scope = (
    client.enums.SeasonalityEventScopeEnum.CHANNEL
)
bidding_seasonality_adjustment.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_seasonality_adjustment.campaigns.append(
#     "INSERT_CAMPAIGN_RESOURCE_NAME_HERE"
# )

bidding_seasonality_adjustment.start_date_time = start_date_time
bidding_seasonality_adjustment.end_date_time = end_date_time
# The conversion_rate_modifier is the expected future conversion rate
# change. When this field is unset or set to 1.0, no adjustment will be
# applied to traffic. The allowed range is 0.1 to 10.0.
bidding_seasonality_adjustment.conversion_rate_modifier = (
    conversion_rate_modifier
)

response = bidding_seasonality_adjustment_service.mutate_bidding_seasonality_adjustments(
    customer_id=customer_id, operations=[operation]
)

resource_name = response.results[0].resource_name

print(f"Added seasonality adjustment with resource name: '{resource_name}'")
      

Ruby

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

operation = client.operation.create_resource.bidding_seasonality_adjustment do |bsa|
  # A unique name is required for every seasonality adjustment.
  bsa.name = "Seasonality Adjustment #{(Time.new.to_f * 1000).to_i}"

  # The CHANNEL scope applies the conversion_rate_modifier 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.
  bsa.scope = :CHANNEL
  bsa.advertising_channel_types << :SEARCH

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

  bsa.start_date_time = start_date_time
  bsa.end_date_time = end_date_time

  # The conversion_rate_modifier is the expected future conversion rate
  # change. When this field is unset or set to 1.0, no adjustment will be
  # applied to traffic. The allowed range is 0.1 to 10.0.
  bsa.conversion_rate_modifier = conversion_rate_modifier
end

response = client.service.bidding_seasonality_adjustment.mutate_bidding_seasonality_adjustments(
  customer_id: customer_id,
  operations: [operation],
)

puts "Added seasonality adjustment with resource name #{response.results.first.resource_name}"
      

Perl

my $seasonality_adjustment =
  Google::Ads::GoogleAds::V16::Resources::BiddingSeasonalityAdjustment->new({
    # A unique name is required for every seasonality adjustment.
    name => "Seasonality adjustment #" . uniqid(),
    # The CHANNEL scope applies the conversion_rate_modifier 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.
    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,
    # The conversion_rate_modifier is the expected future conversion rate change.
    # When this field is unset or set to 1.0, no adjustment will be applied to traffic.
    # The allowed range is 0.1 to 10.0.
    conversionRateModifier => $conversion_rate_modifier
  });

my $operation =
  Google::Ads::GoogleAds::V16::Services::BiddingSeasonalityAdjustmentService::BiddingSeasonalityAdjustmentOperation
  ->new({
    create => $seasonality_adjustment
  });

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

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