您可以使用 Google Ads API,為飯店廣告設定出價調整幅度 (也稱為出價調節係數)。如要進一步瞭解出價調整幅度的運作方式,請參閱「飯店廣告出價調整幅度簡介」。
廣告活動層級出價調整幅度
如要使用 Google Ads API 在廣告活動層級設定出價調整幅度,請參閱「管理出價調節係數」一文。
廣告群組層級出價調整幅度
從第 26 版開始,AdGroupBidModifier 中五項飯店專屬條件會重新命名為不限產業的名稱 (例如預訂開始日和預訂天數),取代舊版中的飯店專屬條件。這些出價調整幅度仍僅支援飯店廣告,包括飯店廣告活動和旅遊搜尋廣告活動。在第 25 版或更早版本中建立的出價調節係數,會自動沿用相同的條件 ID 和資源名稱。如需第 26 版所有破壞性變更的摘要,請參閱版本資訊。
如要在廣告群組層級設定出價調整幅度,請為要指定的維度建立條件物件,並將其欄位設為適當的值。在 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, required. |
預訂開始日期前的天數。有效的bid_modifier範圍:0.1至 10.0,或輸入 0 選擇不採用。 |
hotel_length_of_stay (HotelLengthOfStayInfo) |
length_of_booking (LengthOfBookingInfo) |
min_days,在第 26 版中為 max_days (在第 25 版中為 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在第 26 版中保留現有名稱。
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)
小茹
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 及更新版本進行比較:
25 版和更早版本:
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) 設為有效值 (0.1至10.0,或0以停用advance_booking_window、length_of_booking、start_day_of_week、start_date_range和device;0.5至2.0則適用於user_set_dates)。如要變更指定條件,請移除出價調節係數,然後建立新的出價調節係數。 - 移除:傳送
remove作業,並指定資源名稱:
{
"customerId": "1234567890",
"operations": [
{
"remove": "customers/1234567890/adGroupBidModifiers/987654321~555444333"
}
]
}
驗證規則和錯誤處理
驗證規則在各版本中保持不變,但 v26 中有六個 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:嘗試在不支援的廣告活動類型或不符合資格的搜尋廣告活動中,新增旅遊出價調節係數。