Stay organized with collectionsSave and categorize content based on your preferences.
In order to serve ads for your Hotel campaign, you must create anAdGroupwith at least one ad in the ad group. As shown
later, a Hotel campaign supports only an ad group of theHOTEL_ADStype,
which you can set in thetypefield. The
code example also sets a Percent CPC bid since
the campaign's bidding strategy isPercentCpc.
defadd_hotel_ad_group(client:GoogleAdsClient,customer_id:str,campaign_resource_name:str)->str:ad_group_service:AdGroupServiceClient=client.get_service("AdGroupService")# Create ad group.ad_group_operation:AdGroupOperation=client.get_type("AdGroupOperation")ad_group:AdGroup=ad_group_operation.createad_group.name=f"Earth to Mars cruise{uuid.uuid4()}"ad_group.status=client.enums.AdGroupStatusEnum.ENABLEDad_group.campaign=campaign_resource_name# Sets the ad group type to HOTEL_ADS. This cannot be set to other types.ad_group.type_=client.enums.AdGroupTypeEnum.HOTEL_ADSad_group.cpc_bid_micros=10000000# Add the ad group.ad_group_response:MutateAdGroupsResponse=(ad_group_service.mutate_ad_groups(customer_id=customer_id,operations=[ad_group_operation]))ad_group_resource_name:str=ad_group_response.results[0].resource_nameprint("Added a hotel ad group with resource name '{ad_group_resource_name}'.")returnad_group_resource_name
defadd_hotel_ad_group(client,customer_id,campaign_resource)# Create an ad group.ad_group_operation=client.operation.create_resource.ad_groupdo|ag|ag.name=generate_random_name_field("Earth to Mars Cruise")# Set the campaign.ag.campaign=campaign_resource# Optional: Set the ad group type to HOTEL_ADS.# This cannot be set to other types.ag.type=:HOTEL_ADSag.cpc_bid_micros=10_000_000ag.status=:ENABLEDend# Issue a mutate request to add the ad group.ad_group_service=client.service.ad_groupresponse=ad_group_service.mutate_ad_groups(customer_id:customer_id,operations:[ad_group_operation])# Fetch the new ad group's resource name.ad_group_resource=response.results.first.resource_nameputs"Added hotel ad group with resource name '#{ad_group_resource}'."ad_group_resourceend
subadd_hotel_ad_group{my($api_client,$customer_id,$campaign_resource_name)=@_;# Create an ad group.my$ad_group=Google::Ads::GoogleAds::V21::Resources::AdGroup->new({name=>"Earth to Mars Cruise #".uniqid(),# Set the campaign.campaign=>$campaign_resource_name,# Set the ad group type to HOTEL_ADS.# This cannot be set to other types.type=>HOTEL_ADS,cpcBidMicros=>1000000,status=>Google::Ads::GoogleAds::V21::Enums::AdGroupStatusEnum::ENABLED});# Create an ad group operation.my$ad_group_operation=Google::Ads::GoogleAds::V21::Services::AdGroupService::AdGroupOperation->new({create=>$ad_group});# Add the ad group.my$ad_group_resource_name=$api_client->AdGroupService()->mutate({customerId=>$customer_id,operations=>[$ad_group_operation]})->{results}[0]{resourceName};printf"Added a hotel ad group with resource name: '%s'.\n",$ad_group_resource_name;return$ad_group_resource_name;}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-03 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"]]