You can use the Google Ads API to set bid adjustments (also called bid modifiers) for Hotel ads. For details about the bid adjustments that you can set, see About bid adjustments for Hotel ads .
Campaign level bid adjustments
To use the Google Ads API to set bid adjustments at the campaign level, see Manage bid modifiers .
Ad group level bid adjustments
To use the Google Ads API to set bid adjustments at the ad group level, you need to
first create an object of the relevant class (for example, HotelAdvanceBookingWindowInfo
or HotelDateSelectionTypeInfo
) and then set
its fields to appropriate values.
For instance, if you want to create an ad group bid modifier using an advanced
booking window between 30 and 60 days, you need to create a HotelAdvanceBookingWindowInfo
object and set min_days
to 30 and max_days
to 60.
Finally, associate the relevant object to an AdGroupBidModifier
object. You also have to
specify the resource name of an ad group to which the ad group bid modifier
belongs by using ad_group
.
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 ) . setHotelCheckInDay ( HotelCheckInDayInfo . 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 hotel length of stay info. . setHotelLengthOfStay ( HotelLengthOfStayInfo . newBuilder (). setMinNights ( 3L ). setMaxNights ( 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 . V21 . 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 , HotelCheckInDay = new HotelCheckInDayInfo () { 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 hotel length of stay info. HotelLengthOfStay = new HotelLengthOfStayInfo () { MinNights = 3 , MaxNights = 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; } }