호텔 캠페인 광고를 게재하려면 광고 그룹에 광고가 하나 이상 있는 AdGroup을 만들어야 합니다. 나중에 설명하겠지만 호텔 캠페인은 HOTEL_ADS 유형의 광고 그룹만 지원하며, 이 유형은 type 필드에서 설정할 수 있습니다. 또한 이 코드 예에서는 캠페인의 입찰 전략이 PercentCpc이므로 CPC 비율 입찰가를 설정합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eTo display ads for Hotel campaigns, you need to create an \u003ccode\u003eAdGroup\u003c/code\u003e with at least one ad and set its type to \u003ccode\u003eHOTEL_ADS\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eHotel campaigns exclusively support ad groups of the \u003ccode\u003eHOTEL_ADS\u003c/code\u003e type, which must be specified in the \u003ccode\u003etype\u003c/code\u003e field.\u003c/p\u003e\n"],["\u003cp\u003eSince the campaign's bidding strategy is \u003ccode\u003ePercentCpc\u003c/code\u003e, the code example sets a Percent CPC bid for the ad group.\u003c/p\u003e\n"]]],[],null,["# Creating a Hotel Ad Group\n\nIn order to serve ads for your Hotel campaign, you must create an\n[`AdGroup`](/google-ads/api/reference/rpc/v21/AdGroup) with at least one ad in the ad group. As shown\nlater, a Hotel campaign supports only an ad group of the `HOTEL_ADS` type,\nwhich you can set in the [`type`](/google-ads/api/reference/rpc/v21/AdGroup#type) field. The\ncode example also sets a Percent CPC bid since\nthe campaign's bidding strategy is [`PercentCpc`](/google-ads/api/reference/rpc/v21/PercentCpc).\n\n\n### Java\n\n```java\nprivate String addHotelAdGroup(\n GoogleAdsClient googleAdsClient, long customerId, String campaignResourceName) {\n // Creates an ad group.\n AdGroup adGroup =\n AdGroup.newBuilder()\n .setName(\"Earth to Mars Cruises #\" + getPrintableDateTime())\n .setCampaign(campaignResourceName)\n // Sets the ad group type to HOTEL_ADS. This cannot be set to other types.\n .setType(AdGroupType.HOTEL_ADS)\n .setCpcBidMicros(1_000_000L)\n .setStatus(AdGroupStatus.ENABLED)\n .build();\n\n // Creates an ad group operation.\n AdGroupOperation operation = AdGroupOperation.newBuilder().setCreate(adGroup).build();\n\n // Issues a mutate request to add an ad group.\n try (AdGroupServiceClient adGroupServiceClient =\n googleAdsClient.getLatestVersion().createAdGroupServiceClient()) {\n MutateAdGroupResult mutateAdGroupResult =\n adGroupServiceClient\n .mutateAdGroups(Long.toString(customerId), Collections.singletonList(operation))\n .getResults(0);\n System.out.printf(\n \"Added a hotel ad group with resource name: '%s'%n\",\n mutateAdGroupResult.getResourceName());\n return mutateAdGroupResult.getResourceName();\n }\n}https://github.com/googleads/google-ads-java/blob/3c3c1041c2a0ab81553e3b2a79876256649397ed/google-ads-examples/src/main/java/com/google/ads/googleads/examples/travel/AddHotelAd.java#L273-L301\n \n```\n\n### C#\n\n```c#\nprivate static string AddHotelAdGroup(GoogleAdsClient client, long customerId,\n string campaignResourceName)\n{\n // Get the AdGroupService.\n AdGroupServiceClient service = client.GetService(Services.V21.AdGroupService);\n\n // Create an ad group.\n AdGroup adGroup = new AdGroup()\n {\n Name = \"Earth to Mars Cruise #\" + ExampleUtilities.GetRandomString(),\n\n // Sets the campaign.\n Campaign = campaignResourceName,\n\n // Optional: Sets the ad group type to HOTEL_ADS.\n // This cannot be set to other types.\n Type = AdGroupType.HotelAds,\n\n CpcBidMicros = 10000000,\n Status = AdGroupStatus.Enabled\n };\n\n // Create an ad group operation.\n AdGroupOperation adGroupOperation = new AdGroupOperation()\n {\n Create = adGroup\n };\n\n // Issue a mutate request to add an ad group.\n MutateAdGroupsResponse response = service.MutateAdGroups(customerId.ToString(),\n new AdGroupOperation[] { adGroupOperation });\n return response.Results[0].ResourceName;\n}https://github.com/googleads/google-ads-dotnet/blob/ada966e1983b655e82172b6c3e7d9b091b522377/Google.Ads.GoogleAds/examples/Travel/AddHotelAd.cs#L256-L288\n \n```\n\n### PHP\n\n```php\nprivate static function addHotelAdGroup(\n GoogleAdsClient $googleAdsClient,\n int $customerId,\n string $campaignResourceName\n) {\n // Creates an ad group.\n $adGroup = new AdGroup([\n 'name' =\u003e 'Earth to Mars Cruise #' . Helper::getPrintableDatetime(),\n // Sets the campaign.\n 'campaign' =\u003e $campaignResourceName,\n // Sets the ad group type to HOTEL_ADS.\n // This cannot be set to other types.\n 'type' =\u003e AdGroupType::HOTEL_ADS,\n 'cpc_bid_micros' =\u003e 10000000,\n 'status' =\u003e AdGroupStatus::ENABLED,\n ]);\n\n // Creates an ad group operation.\n $adGroupOperation = new AdGroupOperation();\n $adGroupOperation-\u003esetCreate($adGroup);\n\n // Issues a mutate request to add an ad group.\n $adGroupServiceClient = $googleAdsClient-\u003egetAdGroupServiceClient();\n $response = $adGroupServiceClient-\u003emutateAdGroups(\n MutateAdGroupsRequest::build($customerId, [$adGroupOperation])\n );\n\n /** @var AdGroup $addedAdGroup */\n $addedAdGroup = $response-\u003egetResults()[0];\n printf(\n \"Added a hotel ad group with resource name '%s'.%s\",\n $addedAdGroup-\u003egetResourceName(),\n PHP_EOL\n );\n\n return $addedAdGroup-\u003egetResourceName();\n} \nhttps://github.com/googleads/google-ads-php/blob/be0249c30c27b4760387bec6682b82c9f4167761/examples/Travel/AddHotelAd.php#L282-L318\n\n \n```\n\n### Python\n\n```python\ndef add_hotel_ad_group(\n client: GoogleAdsClient, customer_id: str, campaign_resource_name: str\n) -\u003e str:\n ad_group_service: AdGroupServiceClient = client.get_service(\n \"AdGroupService\"\n )\n\n # Create ad group.\n ad_group_operation: AdGroupOperation = client.get_type(\"AdGroupOperation\")\n ad_group: AdGroup = ad_group_operation.create\n ad_group.name = f\"Earth to Mars cruise {uuid.uuid4()}\"\n ad_group.status = client.enums.AdGroupStatusEnum.ENABLED\n ad_group.campaign = campaign_resource_name\n # Sets the ad group type to HOTEL_ADS. This cannot be set to other types.\n ad_group.type_ = client.enums.AdGroupTypeEnum.HOTEL_ADS\n ad_group.cpc_bid_micros = 10000000\n\n # Add the ad group.\n ad_group_response: MutateAdGroupsResponse = (\n ad_group_service.mutate_ad_groups(\n customer_id=customer_id, operations=[ad_group_operation]\n )\n )\n\n ad_group_resource_name: str = ad_group_response.results[0].resource_name\n\n print(\n \"Added a hotel ad group with resource name '{ad_group_resource_name}'.\"\n )\n\n return ad_group_resource_name \nhttps://github.com/googleads/google-ads-python/blob/d0595698b8a7de6cc00684b467462601037c9db9/examples/travel/add_hotel_ad.py#L159-L189\n \n```\n\n### Ruby\n\n```ruby\ndef add_hotel_ad_group(client, customer_id, campaign_resource)\n # Create an ad group.\n ad_group_operation = client.operation.create_resource.ad_group do |ag|\n ag.name = generate_random_name_field(\"Earth to Mars Cruise\")\n\n # Set the campaign.\n ag.campaign = campaign_resource\n\n # Optional: Set the ad group type to HOTEL_ADS.\n # This cannot be set to other types.\n ag.type = :HOTEL_ADS\n ag.cpc_bid_micros = 10_000_000\n ag.status = :ENABLED\n end\n\n # Issue a mutate request to add the ad group.\n ad_group_service = client.service.ad_group\n response = ad_group_service.mutate_ad_groups(\n customer_id: customer_id,\n operations: [ad_group_operation]\n )\n\n # Fetch the new ad group's resource name.\n ad_group_resource = response.results.first.resource_name\n\n puts \"Added hotel ad group with resource name '#{ad_group_resource}'.\"\n\n ad_group_resource\nend \nhttps://github.com/googleads/google-ads-ruby/blob/2752563c7ffd15a4d2238116869f64aea3011cc3/examples/travel/add_hotel_ad.rb#L134-L162\n\n \n```\n\n### Perl\n\n```perl\nsub add_hotel_ad_group {\n my ($api_client, $customer_id, $campaign_resource_name) = @_;\n\n # Create an ad group.\n my $ad_group = Google::Ads::GoogleAds::V21::Resources::AdGroup-\u003enew({\n name =\u003e \"Earth to Mars Cruise #\" . uniqid(),\n # Set the campaign.\n campaign =\u003e $campaign_resource_name,\n # Set the ad group type to HOTEL_ADS.\n # This cannot be set to other types.\n type =\u003e HOTEL_ADS,\n cpcBidMicros =\u003e 1000000,\n status =\u003e Google::Ads::GoogleAds::V21::Enums::AdGroupStatusEnum::ENABLED\n });\n\n # Create an ad group operation.\n my $ad_group_operation =\n Google::Ads::GoogleAds::V21::Services::AdGroupService::AdGroupOperation-\u003e\n new({create =\u003e $ad_group});\n\n # Add the ad group.\n my $ad_group_resource_name = $api_client-\u003eAdGroupService()-\u003emutate({\n customerId =\u003e $customer_id,\n operations =\u003e [$ad_group_operation]})-\u003e{results}[0]{resourceName};\n\n printf \"Added a hotel ad group with resource name: '%s'.\\n\",\n $ad_group_resource_name;\n\n return $ad_group_resource_name;\n}https://github.com/googleads/google-ads-perl/blob/9abffd69cd856633dfdcee5c636fe9cd0eb4b5ed/examples/travel/add_hotel_ad.pl#L199-L228\n \n```\n\n\u003cbr /\u003e"]]