您可以使用 Google Ads API 为酒店广告设置出价调整(也称为出价调节系数)。如需详细了解出价调整的工作原理,请参阅酒店广告的出价调整简介。
广告系列级出价调整
如需使用 Google Ads API 在广告系列一级设置出价调整,请参阅管理出价调节系数。
广告组级出价调整
从 v26 开始,AdGroupBidModifier 上的五个酒店专属条件已重命名为与行业无关的名称(例如开始日和预订时长),取代了早期版本中的酒店专属条件。这些出价调整仍然仅适用于酒店广告,包括酒店广告系列和旅游搜索广告系列。在 v25 或更早版本中创建的现有出价调节系数会自动沿用,并具有相同的条件 ID 和资源名称。如需查看所有 v26 破坏性更改的摘要,请参阅版本说明。
如需在广告组一级设置出价调整,请为您要定位的维度创建一个条件对象,并将其字段设置为适当的值。在 v26 及更高版本中,请使用与行业无关的标准对象:AdvanceBookingWindowInfo、UserSetDatesInfo、StartDayOfWeekInfo、LengthOfBookingInfo 或 StartDateRangeInfo。在 v25 及更早版本中,请使用酒店专属条件对象:HotelAdvanceBookingWindowInfo、HotelDateSelectionTypeInfo、HotelCheckInDayInfo、HotelLengthOfStayInfo 或 HotelCheckInDateRangeInfo。
下表总结了各个 API 版本中的 AdGroupBidModifier 条件字段、消息类型、子字段和有效 bid_modifier 范围:
| v25 及更低版本 | v26 及更高版本 | 子字段和类型 | 说明和有效范围 |
|---|---|---|---|
hotel_date_selection_type (HotelDateSelectionTypeInfo) |
user_set_dates (UserSetDatesInfo) |
type:在 v26 中为 DateSelectionType(在 v25 中为 HotelDateSelectionType)。值:DEFAULT_SELECTION(条件 ID 50)、USER_SELECTED(条件 ID 51)。IMMUTABLE。 |
默认日期与用户选择的日期。有效的bid_modifier范围:0.5到2.0(不支持0选择退出)。 |
hotel_advance_booking_window (HotelAdvanceBookingWindowInfo) |
advance_booking_window (AdvanceBookingWindowInfo) |
min_days、max_days(int64、0–330)。IMMUTABLE,必需。 |
预订开始日期前的天数。有效的bid_modifier范围:0.1到10.0,或0(选择停用)。 |
hotel_length_of_stay (HotelLengthOfStayInfo) |
length_of_booking (LengthOfBookingInfo) |
min_days,在 v26 中为 max_days(在 v25 中为 min_nights、max_nights)(int64、1–30)。IMMUTABLE,必需。 |
预订时长。有效的bid_modifier范围:0.1 到 10.0,或 0(选择停用)。 |
hotel_check_in_day (HotelCheckInDayInfo) |
start_day_of_week (StartDayOfWeekInfo) |
day_of_week(DayOfWeek,MONDAY–SUNDAY 的标准 ID 为 60–66)。IMMUTABLE。 |
预订开始日期(星期几)。有效的bid_modifier范围:0.1到10.0,或0(选择停用)。 |
hotel_check_in_date_range (HotelCheckInDateRangeInfo) |
start_date_range (StartDateRangeInfo) |
start_date、end_date(string、YYYY-MM-DD)。IMMUTABLE,必需。 |
预订开始日期的日期范围。有效的bid_modifier范围:0.1 到 10.0,或 0(选择停用)。 |
例如,要在 v26 及更高版本中使用 30 到 60 天的提前预订天数创建广告组出价调节系数,请创建一个 AdvanceBookingWindowInfo 对象(或在 v25 及更早版本中创建 HotelAdvanceBookingWindowInfo),并将 min_days 设置为 30,将 max_days 设置为 60。
使用相应的条件字段(advance_booking_window、user_set_dates、start_day_of_week、length_of_booking 或 start_date_range)将条件对象与 AdGroupBidModifier 对象相关联,使用 ad_group 指定目标广告组的资源名称,并将 bid_modifier 字段设置为一个乘数:
advance_booking_window、length_of_booking、start_day_of_week、start_date_range和device:指定一个介于0.1到10.0之间的调节系数(例如,1.5表示 +50% 的调整,0.5表示 -50% 的调整),或将bid_modifier设置为0(0.0) 以停用 (-100%) 该条件。user_set_dates:指定一个介于0.5到2.0之间的调节系数。user_set_dates不支持将bid_modifier设置为0,并会返回RangeError.TOO_LOW。
如需详细了解每种调整类型的运作方式,请参阅酒店广告的出价调整简介。
以下报告细分和资源限制详情也适用于 v26:
segments.user_set_dates:在 v26 及更高版本中,segments.user_set_dates的枚举类型为DateSelectionType(从 v25 及更早版本中的HotelDateSelectionType更新而来;使用segments.hotel_date_selection_type的酒店广告系列报告继续使用HotelDateSelectionType)。其他行程细分(segments.advance_booking_window、segments.length_of_booking、segments.start_date和segments.start_day_of_week)保持不变。- 资源限制:
ResourceLimitType.HOTEL_ADVANCE_BOOKING_WINDOW_BID_MODIFIERS_PER_AD_GROUP和ResourceLimitType.HOTEL_CHECK_IN_DATE_RANGE_BID_MODIFIERS_PER_AD_GROUP在 v26 中保留其现有名称。
Java
private void runExample(GoogleAdsClient googleAdsClient, long customerId, long adGroupId) { List<AdGroupBidModifierOperation> operations = new ArrayList<>(); // Constructs the ad group resource name to use for each bid modifier. String adGroupResourceName = ResourceNames.adGroup(customerId, adGroupId); // 1) Creates an ad group bid modifier based on the hotel check-in day. AdGroupBidModifier checkInDayAdGroupBidModifier = AdGroupBidModifier.newBuilder() // Sets the resource name to the ad group resource name joined with the criterion ID // whose value corresponds to the desired check-in day. .setAdGroup(adGroupResourceName) .setStartDayOfWeek(StartDayOfWeekInfo.newBuilder().setDayOfWeek(DayOfWeek.MONDAY)) // Sets the bid modifier value to 150%. .setBidModifier(1.5d) .build(); operations.add( AdGroupBidModifierOperation.newBuilder().setCreate(checkInDayAdGroupBidModifier).build()); // 2) Creates an ad group bid modifier based on the hotel length of stay. AdGroupBidModifier lengthOfStayAdGroupBidModifier = AdGroupBidModifier.newBuilder() // Sets the ad group. .setAdGroup(adGroupResourceName) // Creates the length of booking info. .setLengthOfBooking( LengthOfBookingInfo.newBuilder().setMinDays(3L).setMaxDays(7L).build()) // Sets the bid modifier value to 170%. .setBidModifier(1.7d) .build(); operations.add( AdGroupBidModifierOperation.newBuilder().setCreate(lengthOfStayAdGroupBidModifier).build()); // Issues a mutate request to add the ad group bid modifiers. try (AdGroupBidModifierServiceClient adGroupBidModifierServiceClient = googleAdsClient.getLatestVersion().createAdGroupBidModifierServiceClient()) { MutateAdGroupBidModifiersResponse response = adGroupBidModifierServiceClient.mutateAdGroupBidModifiers( Long.toString(customerId), operations); // Prints the resource names of the added ad group bid modifiers. System.out.printf("Added %d hotel ad group bid modifiers:%n", response.getResultsCount()); for (MutateAdGroupBidModifierResult mutateAdGroupBidModifierResult : response.getResultsList()) { System.out.printf(" %s%n", mutateAdGroupBidModifierResult.getResourceName()); } } }
C#
public void Run(GoogleAdsClient client, long customerId, long adGroupId) { // Get the AdGroupBidModifierService. AdGroupBidModifierServiceClient service = client.GetService( Services.V26.AdGroupBidModifierService); // Constructs the ad group resource name to use for each bid modifier. string adGroupResourceName = ResourceNames.AdGroup(customerId, adGroupId); // 1) Create an ad group bid modifier based on the hotel check-in day. AdGroupBidModifier checkInDayAdGroupBidModifier = new AdGroupBidModifier() { // Sets the resource name to the ad group resource name joined with the criterion // ID whose value corresponds to the desired check-in day. AdGroup = adGroupResourceName, StartDayOfWeek = new StartDayOfWeekInfo() { DayOfWeek = DayOfWeek.Monday }, // Set the bid modifier value to 150%. BidModifier = 1.5, }; // Creates an ad group bid modifier operation. var checkInDayAdGroupBidModifierOperation = new AdGroupBidModifierOperation() { Create = checkInDayAdGroupBidModifier }; // 2) Create an ad group bid modifier based on the hotel length of stay. AdGroupBidModifier lengthOfStayAdGroupBidModifier = new AdGroupBidModifier() { // Set the ad group. AdGroup = ResourceNames.AdGroup(customerId, adGroupId), // Set the length of booking info. LengthOfBooking = new LengthOfBookingInfo() { MinDays = 3, MaxDays = 7 }, // Set the bid modifier value to 170%. BidModifier = 1.7 }; // Create an ad group bid modifier operation. var lengthOfStayAdGroupBidModifierOperation = new AdGroupBidModifierOperation() { Create = lengthOfStayAdGroupBidModifier }; try { // Issue a mutate request to add an ad group bid modifiers. MutateAdGroupBidModifiersResponse response = service.MutateAdGroupBidModifiers( customerId.ToString(), new AdGroupBidModifierOperation[] { checkInDayAdGroupBidModifierOperation, lengthOfStayAdGroupBidModifierOperation } ); // Display the resource names of the added ad group bid modifiers. Console.WriteLine($"Added {response.Results.Count} hotel ad group bid modifiers:"); foreach (MutateAdGroupBidModifierResult result in response.Results) { Console.WriteLine($"- {result.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
public static function runExample( GoogleAdsClient $googleAdsClient, int $customerId, int $adGroupId ) { $operations = []; // 1) Creates an ad group bid modifier based on the hotel check-in day. $checkInDayAdGroupBidModifier = new AdGroupBidModifier( [ // Sets the ad group. 'ad_group' => ResourceNames::forAdGroup($customerId, $adGroupId), 'hotel_check_in_day' => new HotelCheckInDayInfo( [ 'day_of_week' => DayOfWeek::MONDAY ] ), // Sets the bid modifier value to 150%. 'bid_modifier' => 1.5 ] ); // Creates an ad group bid modifier operation. $checkInDayAdGroupBidModifierOperation = new AdGroupBidModifierOperation(); $checkInDayAdGroupBidModifierOperation->setCreate($checkInDayAdGroupBidModifier); $operations[] = $checkInDayAdGroupBidModifierOperation; // 2) Creates an ad group bid modifier based on the hotel length of stay. $lengthOfStayAdGroupBidModifier = new AdGroupBidModifier( [ // Sets the ad group. 'ad_group' => ResourceNames::forAdGroup($customerId, $adGroupId), // Creates the hotel length of stay info. 'hotel_length_of_stay' => new HotelLengthOfStayInfo( [ 'min_nights' => 3, 'max_nights' => 7, ] ), // Sets the bid modifier value to 170%. 'bid_modifier' => 1.7 ] ); // Creates an ad group bid modifier operation. $lengthOfStayAdGroupBidModifierOperation = new AdGroupBidModifierOperation(); $lengthOfStayAdGroupBidModifierOperation->setCreate( $lengthOfStayAdGroupBidModifier ); $operations[] = $lengthOfStayAdGroupBidModifierOperation; // Issues a mutate request to add an ad group bid modifiers. $adGroupBidModifierServiceClient = $googleAdsClient->getAdGroupBidModifierServiceClient(); $response = $adGroupBidModifierServiceClient->mutateAdGroupBidModifiers( MutateAdGroupBidModifiersRequest::build($customerId, $operations) ); // Print out resource names of the added ad group bid modifiers. printf( "Added %d hotel ad group bid modifiers:%s", $response->getResults()->count(), PHP_EOL ); foreach ($response->getResults() as $addedAdGroupBidModifier) { /** * @var AdGroupBidModifier $addedAdGroupBidModifier */ print $addedAdGroupBidModifier->getResourceName() . PHP_EOL; } }
Python
def main(client: GoogleAdsClient, customer_id: str, ad_group_id: str) -> None: ad_group_service: AdGroupServiceClient = client.get_service( "AdGroupService" ) ag_bm_service: AdGroupBidModifierServiceClient = client.get_service( "AdGroupBidModifierService" ) # Create ad group bid modifier based on hotel check-in day. check_in_ag_bm_operation: AdGroupBidModifierOperation = client.get_type( "AdGroupBidModifierOperation" ) check_in_ag_bid_modifier: AdGroupBidModifier = ( check_in_ag_bm_operation.create ) check_in_ag_bid_modifier.hotel_check_in_day.day_of_week = ( client.enums.DayOfWeekEnum.MONDAY ) check_in_ag_bid_modifier.ad_group = ad_group_service.ad_group_path( customer_id, ad_group_id ) # Sets the bid modifier value to 150%. check_in_ag_bid_modifier.bid_modifier = 1.5 # Create ad group bid modifier based on hotel length of stay info. los_ag_bm_operation: AdGroupBidModifierOperation = client.get_type( "AdGroupBidModifierOperation" ) los_ag_bid_modifier: AdGroupBidModifier = los_ag_bm_operation.create los_ag_bid_modifier.ad_group = ad_group_service.ad_group_path( customer_id, ad_group_id ) # Creates the hotel length of stay info. hotel_length_of_stay_info: HotelLengthOfStayInfo = ( los_ag_bid_modifier.hotel_length_of_stay ) hotel_length_of_stay_info.min_nights = 3 hotel_length_of_stay_info.max_nights = 7 # Sets the bid modifier value to 170%. los_ag_bid_modifier.bid_modifier = 1.7 # Add the bid modifiers ag_bm_response: MutateAdGroupBidModifiersResponse = ( ag_bm_service.mutate_ad_group_bid_modifiers( customer_id=customer_id, operations=[check_in_ag_bm_operation, los_ag_bm_operation], ) ) # Print out resource names of the added ad group bid modifiers. print(f"Added {len(ag_bm_response.results)} hotel ad group bid modifiers:") result: MutateAdGroupBidModifierResult for result in ag_bm_response.results: print(result.resource_name)
Ruby
def add_hotel_ad_group_bid_modifiers(customer_id, ad_group_id) # GoogleAdsClient will read a config file from # ENV['HOME']/google_ads_config.rb when called without parameters client = Google::Ads::GoogleAds::GoogleAdsClient.new operations = [] ad_group_resource = client.path.ad_group(customer_id, ad_group_id) # 1) Creates an ad group bid modifier based on the check-in day. operations << client.operation.create_resource.ad_group_bid_modifier do |bm| # Sets the ad group. bm.ad_group = ad_group_resource # Sets the check-in day to Monday. bm.start_day_of_week = client.resource.start_day_of_week_info do |info| info.day_of_week = :MONDAY end # Sets the bid modifier value to 150%. bm.bid_modifier = 1.5 end # 2) Creates an ad group bid modifier based on the length of booking. operations << client.operation.create_resource.ad_group_bid_modifier do |bm| # Sets the ad group. bm.ad_group = ad_group_resource # Creates the length of booking info. bm.length_of_booking = client.resource.length_of_booking_info do |info| info.min_days = 3 info.max_days = 7 end # Sets the bid modifier value to 170%. bm.bid_modifier = 1.7 end # 3) Issues a mutate request to add an ad group bid modifiers. ad_group_bid_modifier_service = client.service.ad_group_bid_modifier response = ad_group_bid_modifier_service.mutate_ad_group_bid_modifiers( customer_id: customer_id, operations: operations, ) # Print out resource names of the added ad group bid modifiers. puts "Added #{response.results.size} hotel ad group bid modifiers:" response.results.each do |added_ad_group_bid_modifier| puts "\t#{added_ad_group_bid_modifier.resource_name}" end end
Perl
sub add_hotel_ad_group_bid_modifiers { my ($api_client, $customer_id, $ad_group_id) = @_; # 1) Create an ad group bid modifier based on the hotel check-in day. my $check_in_day_ad_group_bid_modifier = Google::Ads::GoogleAds::V26::Resources::AdGroupBidModifier->new({ # Set the ad group. adGroup => Google::Ads::GoogleAds::V26::Utils::ResourceNames::ad_group( $customer_id, $ad_group_id ), hotelCheckInDay => Google::Ads::GoogleAds::V26::Common::HotelCheckInDayInfo->new({ dayOfWeek => MONDAY } ), # Set the bid modifier value to 150%. bidModifier => 1.5 }); # Create an ad group bid modifier operation. my $check_in_day_ad_group_bid_modifier_operation = Google::Ads::GoogleAds::V26::Services::AdGroupBidModifierService::AdGroupBidModifierOperation ->new({ create => $check_in_day_ad_group_bid_modifier }); # 2) Create an ad group bid modifier based on the hotel length of stay. my $length_of_stay_ad_group_bid_modifier = Google::Ads::GoogleAds::V26::Resources::AdGroupBidModifier->new({ # Set the ad group. adGroup => Google::Ads::GoogleAds::V26::Utils::ResourceNames::ad_group( $customer_id, $ad_group_id ), # Create the hotel length of stay info. hotelLengthOfStay => Google::Ads::GoogleAds::V26::Common::HotelLengthOfStayInfo->new({ minNights => 3, maxNights => 7 } ), # Set the bid modifier value to 170%. bidModifier => 1.7 }); # Create an ad group bid modifier operation. my $length_of_stay_ad_group_bid_modifier_operation = Google::Ads::GoogleAds::V26::Services::AdGroupBidModifierService::AdGroupBidModifierOperation ->new({ create => $length_of_stay_ad_group_bid_modifier }); # 3) Add the ad group bid modifiers. my $ad_group_bid_modifiers_response = $api_client->AdGroupBidModifierService()->mutate({ customerId => $customer_id, operations => [ $check_in_day_ad_group_bid_modifier_operation, $length_of_stay_ad_group_bid_modifier_operation ]}); # Print out resource names of the added ad group bid modifiers. my $ad_group_bid_modifier_results = $ad_group_bid_modifiers_response->{results}; printf "Added %d hotel ad group bid modifiers:\n", scalar @$ad_group_bid_modifier_results; foreach my $ad_group_bid_modifier_result (@$ad_group_bid_modifier_results) { printf "\t%s\n", $ad_group_bid_modifier_result->{resourceName}; } return 1; }
curl
示例
以下示例展示了如何使用 GAQL 和 REST JSON 载荷查询、创建、更新和移除广告组出价调节系数。
使用 GAQL 读取出价调节系数
以下查询展示了在 v25 及更早版本中与在 v26 及更高版本中检索入住时长出价调节系数的区别:
v25 及更低版本:
SELECT
ad_group_bid_modifier.resource_name,
ad_group_bid_modifier.bid_modifier,
ad_group_bid_modifier.hotel_length_of_stay.min_nights,
ad_group_bid_modifier.hotel_length_of_stay.max_nights
FROM ad_group_bid_modifier
WHERE ad_group_bid_modifier.hotel_length_of_stay.min_nights = 5
v26 及更高版本:
SELECT
ad_group_bid_modifier.resource_name,
ad_group_bid_modifier.bid_modifier,
ad_group_bid_modifier.length_of_booking.min_days,
ad_group_bid_modifier.length_of_booking.max_days
FROM ad_group_bid_modifier
WHERE ad_group_bid_modifier.length_of_booking.min_days = 5
创建出价调节系数(JSON 载荷)
以下 JSON 载荷演示了如何在 v26 及更高版本中创建广告组出价调节系数。
在 v26 中创建预订时长出价调节系数:
{
"customerId": "1234567890",
"operations": [
{
"create": {
"adGroup": "customers/1234567890/adGroups/987654321",
"bidModifier": 1.2,
"lengthOfBooking": {
"minDays": "3",
"maxDays": "5"
}
}
}
]
}
在 v25 及更低版本中,此操作使用 hotelLengthOfStay 以及 minNights 和 maxNights。
在 v26 中创建开始日期范围出价调节系数:
{
"customerId": "1234567890",
"operations": [
{
"create": {
"adGroup": "customers/1234567890/adGroups/987654321",
"bidModifier": 1.5,
"startDateRange": {
"startDate": "2026-12-20",
"endDate": "2026-12-31"
}
}
}
]
}
在 v26 中创建用户设置的日期出价调整:
{
"customerId": "1234567890",
"operations": [
{
"create": {
"adGroup": "customers/1234567890/adGroups/987654321",
"bidModifier": 1.3,
"userSetDates": {
"type": "USER_SELECTED"
}
}
}
]
}
更新和移除出价调节系数
您可以更新现有出价调节系数的乘数,也可以完全移除出价调节系数:
- 更新:条件字段为
IMMUTABLE。如需修改出价调节系数,请发送update操作,并将updateMask(在 protobuf 中为update_mask)设置为"bidModifier"("bid_modifier"),将bidModifier(bid_modifier) 设置为有效值(对于advance_booking_window、length_of_booking、start_day_of_week、start_date_range和device,设置为0.1到10.0,或设置为0以停用;对于user_set_dates,设置为0.5到2.0)。如需更改定位条件,请移除出价调节系数并创建一个新的出价调节系数。 - 移除:发送包含资源名称的
remove操作:
{
"customerId": "1234567890",
"operations": [
{
"remove": "customers/1234567890/adGroupBidModifiers/987654321~555444333"
}
]
}
验证规则和错误处理
验证规则在各个版本中保持不变,但 v26 中重命名了 6 个 CriterionError 枚举值,如下表所示:
| 场景 | v25 及更低版本 | v26 及更高版本 |
|---|---|---|
| 预订时长范围与现有条件重叠 | HOTEL_LENGTH_OF_STAY_OVERLAPS_WITH_EXISTING_CRITERION |
LENGTH_OF_BOOKING_OVERLAPS_WITH_EXISTING_CRITERION |
| 提前预订天数范围与现有条件重叠 | HOTEL_ADVANCE_BOOKING_WINDOW_OVERLAPS_WITH_EXISTING_CRITERION |
ADVANCE_BOOKING_WINDOW_OVERLAPS_WITH_EXISTING_CRITERION |
| 开始日期范围与现有条件重叠 | HOTEL_CHECK_IN_DATE_RANGE_OVERLAPS_WITH_EXISTING_CRITERION |
START_DATE_RANGE_OVERLAPS_WITH_EXISTING_CRITERION |
比昨天(世界协调时间)早 start_date |
HOTEL_CHECK_IN_DATE_RANGE_START_DATE_TOO_EARLY |
START_DATE_RANGE_START_DATE_TOO_EARLY |
end_date 个日期在 330 天之后(世界协调时间) |
HOTEL_CHECK_IN_DATE_RANGE_END_DATE_TOO_LATE |
START_DATE_RANGE_END_DATE_TOO_LATE |
start_date,end_date 之后 |
HOTEL_CHECK_IN_DATE_RANGE_REVERSED |
START_DATE_RANGE_REVERSED |
以下验证错误适用于所有 API 版本:
FieldError.REQUIRED:缺少必需的范围边界(例如,advance_booking_window没有min_days或max_days)。RangeError.TOO_HIGH/RangeError.TOO_LOW:值超出范围,例如advance_booking_window.max_days大于 330、min_days大于max_days(在advance_booking_window或length_of_booking上)、bid_modifier超出0.1–10.0(对于advance_booking_window、length_of_booking、start_day_of_week或start_date_range),或bid_modifier超出0.5–2.0(包括0,对于user_set_dates)。ResourceCountLimitExceededError.RESOURCE_LIMIT:广告组超出了每个广告组的出价调节系数上限。MutateError.INCONSISTENT_FIELD_VALUES:固定 ID 枚举子字段(例如user_set_dates.type、start_day_of_week.day_of_week或device.type)与resource_name中指定的条件 ID 不匹配。ContextError.OPERATION_NOT_PERMITTED_FOR_CONTEXT:尝试在不受支持的广告系列类型或不符合条件的搜索广告系列中添加旅行出价调节系数。