Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Per pubblicare annunci per la tua campagna per hotel, devi creare un
AdGroup con almeno un annuncio nel gruppo di annunci. Come mostrato
in seguito, una campagna per hotel supporta solo un gruppo di annunci di tipo HOTEL_ADS,
che puoi impostare nel campo type. L'esempio di codice imposta anche un'offerta CPC percentuale, poiché la strategia di offerta della campagna è PercentCpc.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-06 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,["In 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\nJava \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/e5d86e34c0a6ec321f9d8adeaa38102e1ce19498/google-ads-examples/src/main/java/com/google/ads/googleads/examples/travel/AddHotelAd.java#L273-L301\n \n```\n\nC# \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\nPHP \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\nPython \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/c7535c7e2a8f87bb6abbad4c4b4ea05d5b4593b4/examples/travel/add_hotel_ad.py#L159-L189\n \n```\n\nRuby \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/9939642cd39ccdd2ae0893a4510b85870e1ba682/examples/travel/add_hotel_ad.rb#L134-L162\n\n \n```\n\nPerl \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"]]