[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eHotel Ads are created by first defining an \u003ccode\u003eAd\u003c/code\u003e with \u003ccode\u003eHotelAdInfo\u003c/code\u003e and then linking it to an \u003ccode\u003eAdGroupAd\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eTo enable ad serving, the \u003ccode\u003eAdGroupAd\u003c/code\u003e must have its \u003ccode\u003estatus\u003c/code\u003e set to \u003ccode\u003eENABLED\u003c/code\u003e and be associated with an active \u003ccode\u003eAd\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eWhile multiple ad group ads can exist within a Hotel ad group, it's recommended to use only one per ad group for clearer performance metrics.\u003c/p\u003e\n"],["\u003cp\u003ePausing Hotel Ads should be done at the ad group or campaign level, not by setting the \u003ccode\u003eAdGroupAd\u003c/code\u003e status to paused.\u003c/p\u003e\n"]]],[],null,["# Creating a Hotel Ad Group Ad\n\nCreating a Hotel ad involves two steps:\n\n1. Creating an [`Ad`](/google-ads/api/reference/rpc/v21/Ad) and setting its\n [`hotel_ad`](/google-ads/api/reference/rpc/v21/Ad#hotel_ad) to an instance of\n [`HotelAdInfo`](/google-ads/api/reference/rpc/v21/HotelAdInfo).\n\n2. Creating an [`AdGroupAd`](/google-ads/api/reference/rpc/v21/AdGroupAd) and associating the\n previously created `Ad` to it.\n\n| **Key Point:** In order to serve Hotel Ads for your ad group, you need one [`AdGroupAd`](/google-ads/api/reference/rpc/v21/AdGroupAd) whose [`ad`](/google-ads/api/reference/rpc/v21/AdGroupAd#ad) is set and whose [`status`](/google-ads/api/reference/rpc/v21/AdGroupAd#status) is [`ENABLED`](/google-ads/api/reference/rpc/v21/AdGroupAdStatusEnum.AdGroupAdStatus#enabled) (you can use [queries](/google-ads/api/docs/hotel-ads/reporting) to check these values). You can create more than one ad group ad in a Hotel ad group, but the serving of the ad group ads are arbitrary, resulting in impressions that are shared among the whole lot of ads. Therefore, we recommend creating only one ad group ad per ad group, so you can distinguish metrics more easily.\n\n\n### Java\n\n```java\nprivate String addHotelAdGroupAd(\n GoogleAdsClient googleAdsClient, long customerId, String adGroupResourceName) {\n // Creates a new hotel ad.\n Ad ad = Ad.newBuilder().setHotelAd(HotelAdInfo.newBuilder().build()).build();\n // Creates a new ad group ad and sets the hotel ad to it.\n AdGroupAd adGroupAd =\n AdGroupAd.newBuilder()\n // Sets the ad to the ad created above.\n .setAd(ad)\n // Set the ad group ad to enabled. Setting this to paused will cause an error\n // for hotel campaigns. For hotels pausing should happen at either the ad group or\n // campaign level.\n .setStatus(AdGroupAdStatus.ENABLED)\n // Sets the ad group.\n .setAdGroup(adGroupResourceName)\n .build();\n\n // Creates an ad group ad operation.\n AdGroupAdOperation operation = AdGroupAdOperation.newBuilder().setCreate(adGroupAd).build();\n\n // Issues a mutate request to add an ad group ad.\n try (AdGroupAdServiceClient adGroupAdServiceClient =\n googleAdsClient.getLatestVersion().createAdGroupAdServiceClient()) {\n MutateAdGroupAdResult mutateAdGroupAdResult =\n adGroupAdServiceClient\n .mutateAdGroupAds(Long.toString(customerId), Collections.singletonList(operation))\n .getResults(0);\n System.out.printf(\n \"Added a hotel ad group ad with resource name: '%s'%n\",\n mutateAdGroupAdResult.getResourceName());\n return mutateAdGroupAdResult.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#L315-L347\n \n```\n\n### C#\n\n```c#\nprivate static void AddHotelAdGroupAd(GoogleAdsClient client, long customerId,\n string adGroupResourceName)\n{\n // Get the AdGroupAdService.\n AdGroupAdServiceClient service = client.GetService(Services.V21.AdGroupAdService);\n\n // Create a new ad group ad and sets the hotel ad to it.\n AdGroupAd adGroupAd = new AdGroupAd()\n {\n // Create a new hotel ad.\n Ad = new Ad()\n {\n HotelAd = new HotelAdInfo(),\n },\n // Set the ad group.\n AdGroup = adGroupResourceName,\n // Set the ad group ad to enabled. Setting this to paused will cause an error\n // for hotel campaigns. For hotels pausing should happen at either the ad group or\n // campaign level.\n Status = AdGroupAdStatus.Enabled\n };\n\n // Create an ad group ad operation.\n AdGroupAdOperation adGroupAdOperation = new AdGroupAdOperation()\n {\n Create = adGroupAd\n };\n\n // Issue a mutate request to add an ad group ad.\n MutateAdGroupAdsResponse response = service.MutateAdGroupAds(customerId.ToString(),\n new AdGroupAdOperation[] { adGroupAdOperation });\n\n MutateAdGroupAdResult addedAdGroupAd = response.Results[0];\n Console.WriteLine($\"Added a hotel ad group ad with resource name \" +\n $\"{addedAdGroupAd.ResourceName}.\");\n}https://github.com/googleads/google-ads-dotnet/blob/ada966e1983b655e82172b6c3e7d9b091b522377/Google.Ads.GoogleAds/examples/Travel/AddHotelAd.cs#L299-L334\n \n```\n\n### PHP\n\n```php\nprivate static function addHotelAdGroupAd(\n GoogleAdsClient $googleAdsClient,\n int $customerId,\n string $adGroupResourceName\n) {\n // Creates a new hotel ad.\n $ad = new Ad([\n 'hotel_ad' =\u003e new HotelAdInfo(),\n ]);\n\n // Creates a new ad group ad and sets the hotel ad to it.\n $adGroupAd = new AdGroupAd([\n 'ad' =\u003e $ad,\n // Set the ad group ad to enabled. Setting this to paused will cause an error\n // for hotel campaigns. For hotels pausing should happen at either the ad group or\n // campaign level.\n 'status' =\u003e AdGroupAdStatus::ENABLED,\n // Sets the ad group.\n 'ad_group' =\u003e $adGroupResourceName\n ]);\n\n // Creates an ad group ad operation.\n $adGroupAdOperation = new AdGroupAdOperation();\n $adGroupAdOperation-\u003esetCreate($adGroupAd);\n\n // Issues a mutate request to add an ad group ad.\n $adGroupAdServiceClient = $googleAdsClient-\u003egetAdGroupAdServiceClient();\n $response = $adGroupAdServiceClient-\u003emutateAdGroupAds(\n MutateAdGroupAdsRequest::build($customerId, [$adGroupAdOperation])\n );\n\n /** @var AdGroupAd $addedAdGroupAd */\n $addedAdGroupAd = $response-\u003egetResults()[0];\n printf(\n \"Added a hotel ad group ad with resource name '%s'.%s\",\n $addedAdGroupAd-\u003egetResourceName(),\n PHP_EOL\n );\n} \nhttps://github.com/googleads/google-ads-php/blob/be0249c30c27b4760387bec6682b82c9f4167761/examples/Travel/AddHotelAd.php#L330-L368\n\n \n```\n\n### Python\n\n```python\ndef add_hotel_ad(\n client: GoogleAdsClient, customer_id: str, ad_group_resource_name: str\n) -\u003e str:\n ad_group_ad_service: AdGroupAdServiceClient = client.get_service(\n \"AdGroupAdService\"\n )\n\n # Creates a new ad group ad and sets the hotel ad to it.\n ad_group_ad_operation: AdGroupAdOperation = client.get_type(\n \"AdGroupAdOperation\"\n )\n ad_group_ad: AdGroupAd = ad_group_ad_operation.create\n ad_group_ad.ad_group = ad_group_resource_name\n # Set the ad group ad to enabled. Setting this to paused will cause an error\n # for hotel campaigns. For hotels pausing should happen at either the ad group or\n # campaign level.\n ad_group_ad.status = client.enums.AdGroupAdStatusEnum.ENABLED\n client.copy_from(ad_group_ad.ad.hotel_ad, client.get_type(\"HotelAdInfo\"))\n\n # Add the ad group ad.\n ad_group_ad_response: MutateAdGroupAdsResponse = (\n ad_group_ad_service.mutate_ad_group_ads(\n customer_id=customer_id, operations=[ad_group_ad_operation]\n )\n )\n\n ad_group_ad_resource_name: str = ad_group_ad_response.results[\n 0\n ].resource_name\n\n print(f\"Created hotel ad with resource name '{ad_group_ad_resource_name}'.\")\n\n return ad_group_resource_name \nhttps://github.com/googleads/google-ads-python/blob/d0595698b8a7de6cc00684b467462601037c9db9/examples/travel/add_hotel_ad.py#L122-L154\n \n```\n\n### Ruby\n\n```ruby\ndef add_hotel_ad_group_ad(client, customer_id, ad_group_resource)\n # Create a new hotel ad.\n ad_group_ad_operation = client.operation.create_resource.ad_group_ad do |aga|\n # Create a new ad group ad and sets the hotel ad to it.\n aga.ad = client.resource.ad do |ad|\n ad.hotel_ad = client.resource.hotel_ad_info\n end\n # Set the ad group ad to enabled. Setting this to paused will cause an error\n # for hotel campaigns. For hotels pausing should happen at either the ad group or\n # campaign level.\n aga.status = :ENABLED\n\n # Set the ad group.\n aga.ad_group = ad_group_resource\n end\n\n # Issue a mutate request to add the ad group ad.\n ad_group_ad_service = client.service.ad_group_ad\n response = ad_group_ad_service.mutate_ad_group_ads(\n customer_id: customer_id,\n operations: [ad_group_ad_operation],\n )\n\n # Fetch the new ad group ad's resource name.\n ad_group_ad_resource = response.results.first.resource_name\n\n puts \"Added hotel ad group ad with resource name '#{ad_group_ad_resource}'.\"\nend \nhttps://github.com/googleads/google-ads-ruby/blob/2752563c7ffd15a4d2238116869f64aea3011cc3/examples/travel/add_hotel_ad.rb#L167-L194\n\n \n```\n\n### Perl\n\n```perl\nsub add_hotel_ad_group_ad {\n my ($api_client, $customer_id, $ad_group_resource_name) = @_;\n\n # Create an ad group ad and set a hotel ad to it.\n my $ad_group_ad = Google::Ads::GoogleAds::V21::Resources::AdGroupAd-\u003enew({\n # Set the ad group.\n adGroup =\u003e $ad_group_resource_name,\n # Set the ad to a new shopping product ad.\n ad =\u003e Google::Ads::GoogleAds::V21::Resources::Ad-\u003enew({\n hotelAd =\u003e Google::Ads::GoogleAds::V21::Common::HotelAdInfo-\u003enew()}\n ),\n status =\u003e Google::Ads::GoogleAds::V21::Enums::AdGroupAdStatusEnum::ENABLED\n });\n\n # Create an ad group ad operation.\n my $ad_group_ad_operation =\n Google::Ads::GoogleAds::V21::Services::AdGroupAdService::AdGroupAdOperation\n -\u003enew({create =\u003e $ad_group_ad});\n\n # Add the ad group ad.\n my $ad_group_ad_resource_name = $api_client-\u003eAdGroupAdService()-\u003emutate({\n customerId =\u003e $customer_id,\n operations =\u003e [$ad_group_ad_operation]})-\u003e{results}[0]{resourceName};\n\n printf \"Added a hotel ad group ad with resource name: '%s'.\\n\",\n $ad_group_ad_resource_name;\n\n return $ad_group_ad_resource_name;\n}https://github.com/googleads/google-ads-perl/blob/9abffd69cd856633dfdcee5c636fe9cd0eb4b5ed/examples/travel/add_hotel_ad.pl#L233-L261\n \n```\n\n\u003cbr /\u003e"]]