2121import com .google .ads .googleads .lib .GoogleAdsException ;
2222import com .google .ads .googleads .v0 .common .Ad ;
2323import com .google .ads .googleads .v0 .common .HotelAdInfo ;
24- import com .google .ads .googleads .v0 .common .ManualCpc ;
24+ import com .google .ads .googleads .v0 .common .PercentCpc ;
2525import com .google .ads .googleads .v0 .enums .AdGroupAdStatusEnum .AdGroupAdStatus ;
2626import com .google .ads .googleads .v0 .enums .AdGroupStatusEnum .AdGroupStatus ;
2727import com .google .ads .googleads .v0 .enums .AdGroupTypeEnum .AdGroupType ;
@@ -72,6 +72,9 @@ private static class AddHotelAdParams extends CodeSampleParams {
7272
7373 @ Parameter (names = ArgumentNames .HOTEL_CENTER_ACCOUNT_ID , required = true )
7474 private Long hotelCenterAccountId ;
75+
76+ @ Parameter (names = ArgumentNames .CPC_BID_CEILING_MICRO_AMOUNT )
77+ private Long cpcBidCeilingMicroAmount = 20_000_000L ;
7578 }
7679
7780 public static void main (String [] args ) {
@@ -82,6 +85,7 @@ public static void main(String[] args) {
8285 // into the code here. See the parameter class definition above for descriptions.
8386 params .customerId = Long .parseLong ("INSERT_CUSTOMER_ID_HERE" );
8487 params .hotelCenterAccountId = Long .parseLong ("INSERT_HOTEL_CENTER_ACCOUNT_ID_HERE" );
88+ params .cpcBidCeilingMicroAmount = Long .parseLong ("INSERT_CPC_BID_CEILING_MICRO_AMOUNT_HERE" );
8589 }
8690
8791 GoogleAdsClient googleAdsClient ;
@@ -97,7 +101,12 @@ public static void main(String[] args) {
97101 }
98102
99103 try {
100- new AddHotelAd ().runExample (googleAdsClient , params .customerId , params .hotelCenterAccountId );
104+ new AddHotelAd ()
105+ .runExample (
106+ googleAdsClient ,
107+ params .customerId ,
108+ params .hotelCenterAccountId ,
109+ params .cpcBidCeilingMicroAmount );
101110 } catch (GoogleAdsException gae ) {
102111 // GoogleAdsException is the base class for most exceptions thrown by an API request.
103112 // Instances of this exception have a message and a GoogleAdsFailure that contains a
@@ -119,17 +128,27 @@ public static void main(String[] args) {
119128 * @param googleAdsClient the Google Ads API client.
120129 * @param customerId the client customer ID.
121130 * @param hotelCenterAccountId the Hotel Center account ID.
131+ * @param cpcBidCeilingMicroAmount the maximum bid limit that can be set when creating a campaign
132+ * using the Percent CPC bidding strategy.
122133 * @throws GoogleAdsException if an API request failed with one or more service errors.
123134 */
124135 private void runExample (
125- GoogleAdsClient googleAdsClient , long customerId , long hotelCenterAccountId ) {
136+ GoogleAdsClient googleAdsClient ,
137+ long customerId ,
138+ long hotelCenterAccountId ,
139+ long cpcBidCeilingMicroAmount ) {
126140
127141 // Creates a budget to be used by the campaign that will be created below.
128142 String budgetResourceName = addCampaignBudget (googleAdsClient , customerId );
129143
130144 // Creates a hotel campaign.
131145 String campaignResourceName =
132- addHotelCampaign (googleAdsClient , customerId , budgetResourceName , hotelCenterAccountId );
146+ addHotelCampaign (
147+ googleAdsClient ,
148+ customerId ,
149+ budgetResourceName ,
150+ hotelCenterAccountId ,
151+ cpcBidCeilingMicroAmount );
133152
134153 // Creates a hotel ad group.
135154 String adGroupResourceName = addHotelAdGroup (googleAdsClient , customerId , campaignResourceName );
@@ -174,14 +193,17 @@ private String addCampaignBudget(GoogleAdsClient googleAdsClient, long customerI
174193 * @param customerId the client customer ID.
175194 * @param budgetResourceName the resource name of the budget for the campaign.
176195 * @param hotelCenterAccountId the Hotel Center account ID.
196+ * @param cpcBidCeilingMicroAmount the maximum bid limit that can be set when creating a campaign
197+ * using the Percent CPC bidding strategy.
177198 * @return resource name of the newly created campaign.
178199 * @throws GoogleAdsException if an API request failed with one or more service errors.
179200 */
180201 private String addHotelCampaign (
181202 GoogleAdsClient googleAdsClient ,
182203 long customerId ,
183204 String budgetResourceName ,
184- long hotelCenterAccountId ) {
205+ long hotelCenterAccountId ,
206+ long cpcBidCeilingMicroAmount ) {
185207
186208 // Configures the hotel settings.
187209 HotelSettingInfo hotelSettingInfo =
@@ -204,8 +226,12 @@ private String addHotelCampaign(
204226 // the ads from immediately serving. Set to ENABLED once you've added
205227 // targeting and the ads are ready to serve
206228 .setStatus (CampaignStatus .PAUSED )
207- // Sets the bidding strategy. Only Manual CPC can be used for hotel campaigns.
208- .setManualCpc (ManualCpc .newBuilder ().build ())
229+ // Sets the bidding strategy to Percent CPC. Only Manual CPC and Percent CPC can be used
230+ // for hotel campaigns.
231+ .setPercentCpc (
232+ PercentCpc .newBuilder ()
233+ .setCpcBidCeilingMicros (Int64Value .of (cpcBidCeilingMicroAmount ))
234+ .build ())
209235 // Sets the budget.
210236 .setCampaignBudget (StringValue .of (budgetResourceName ))
211237 // Adds the networkSettings configured above.
0 commit comments