Der erste Schritt bei der Implementierung von Hotelanzeigen besteht darin, eine Hotelkampagne zu erstellen. Wenn Sie eine Hotelkampagne erstellen, legen Sie das Budget, die Gebotsstrategie und die Hotel Center-Konto-ID fest.
So richten Sie eine Hotelkampagne ein:
- Legen Sie den
advertising_channel_type
der Kampagne aufHOTEL
fest. - Erstellen Sie eine
HotelSettingInfo
, legen Sie diehotel_center_id
fest und fügen Sie sie der Kampagne hinzu. - Erstellen Sie eine
PercentCpc
-Gebotsstrategie für die Kampagne. Weitere Informationen zu Gebotsstrategien und zum Festlegen von Geboten finden Sie unter Gebote.
Diese Schritte werden im folgenden Code veranschaulicht.
Java
private void runExample( GoogleAdsClient googleAdsClient, long customerId, long hotelCenterAccountId, long cpcBidCeilingMicroAmount) { // Creates a budget to be used by the campaign that will be created below. String budgetResourceName = addCampaignBudget(googleAdsClient, customerId); // Creates a hotel campaign. String campaignResourceName = addHotelCampaign( googleAdsClient, customerId, budgetResourceName, hotelCenterAccountId, cpcBidCeilingMicroAmount); // Creates a hotel ad group. String adGroupResourceName = addHotelAdGroup(googleAdsClient, customerId, campaignResourceName); // Creates a hotel ad group ad. addHotelAdGroupAd(googleAdsClient, customerId, adGroupResourceName); }
C#
public void Run(GoogleAdsClient client, long customerId, long hotelCenterAccountId, long cpcBidCeilingMicroAmount) { try { // Create a budget to be used by the campaign that will be created below. string budgetResourceName = AddCampaignBudget(client, customerId); // Create a hotel campaign. string campaignResourceName = AddHotelCampaign(client, customerId, budgetResourceName, hotelCenterAccountId, cpcBidCeilingMicroAmount); // Create a hotel ad group. string adGroupResourceName = AddHotelAdGroup(client, customerId, campaignResourceName); // Create a hotel ad group ad. AddHotelAdGroupAd(client, customerId, adGroupResourceName); } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
PHP
private static function addHotelCampaign( GoogleAdsClient $googleAdsClient, int $customerId, string $budgetResourceName, int $hotelCenterAccountId, int $cpcBidCeilingMicroAmount ) { // Creates a campaign. $campaign = new Campaign([ 'name' => 'Interplanetary Cruise Campaign #' . Helper::getPrintableDatetime(), // Configures settings related to hotel campaigns including advertising channel type // and hotel setting info. 'advertising_channel_type' => AdvertisingChannelType::HOTEL, 'hotel_setting' => new HotelSettingInfo(['hotel_center_id' => $hotelCenterAccountId]), // Recommendation: Set the campaign to PAUSED when creating it to prevent // the ads from immediately serving. Set to ENABLED once you've added // targeting and the ads are ready to serve. 'status' => CampaignStatus::PAUSED, // Sets the bidding strategy to PercentCpc. Only Manual CPC and Percent CPC can be used // for hotel campaigns. 'percent_cpc' => new PercentCpc([ 'cpc_bid_ceiling_micros' => $cpcBidCeilingMicroAmount ]), // Sets the budget. 'campaign_budget' => $budgetResourceName, // Configures the campaign network options. Only Google Search is allowed for // hotel campaigns. 'network_settings' => new NetworkSettings([ 'target_google_search' => true, ]), ]); // Creates a campaign operation. $campaignOperation = new CampaignOperation(); $campaignOperation->setCreate($campaign); // Issues a mutate request to add campaigns. $campaignServiceClient = $googleAdsClient->getCampaignServiceClient(); $response = $campaignServiceClient->mutateCampaigns( MutateCampaignsRequest::build($customerId, [$campaignOperation]) ); /** @var Campaign $addedCampaign */ $addedCampaign = $response->getResults()[0]; printf( "Added a hotel campaign with resource name '%s'.%s", $addedCampaign->getResourceName(), PHP_EOL ); return $addedCampaign->getResourceName(); }
Python
def add_hotel_campaign( client, customer_id, budget_resource_name, hotel_center_account_id, cpc_bid_ceiling_micro_amount, ): campaign_service = client.get_service("CampaignService") # Create campaign. campaign_operation = client.get_type("CampaignOperation") campaign = campaign_operation.create campaign.name = f"Interplanetary Cruise Campaign {uuid.uuid4()}" # Configures settings related to hotel campaigns including advertising # channel type and hotel setting info. campaign.advertising_channel_type = ( client.enums.AdvertisingChannelTypeEnum.HOTEL ) campaign.hotel_setting.hotel_center_id = hotel_center_account_id # Recommendation: Set the campaign to PAUSED when creating it to prevent the # ads from immediately serving. Set to ENABLED once you've added targeting # and the ads are ready to serve. campaign.status = client.enums.CampaignStatusEnum.PAUSED # Set the bidding strategy to PercentCpc. Only Manual CPC and Percent CPC # can be used for hotel campaigns. campaign.percent_cpc.cpc_bid_ceiling_micros = cpc_bid_ceiling_micro_amount # Sets the budget. campaign.campaign_budget = budget_resource_name # Set the campaign network options. Only Google Search is allowed for hotel # campaigns. campaign.network_settings.target_google_search = True # Add the campaign. campaign_response = campaign_service.mutate_campaigns( customer_id=customer_id, operations=[campaign_operation] ) campaign_resource_name = campaign_response.results[0].resource_name print( "Added a hotel campaign with resource name '{campaign_resource_name}'." ) return campaign_resource_name
Ruby
def add_hotel_campaign(client, customer_id, budget_resource, hotel_center_account_id, cpc_bid_ceiling_micro_amount) # Create a campaign. campaign_operation = client.operation.create_resource.campaign do |c| c.name = generate_random_name_field("Interplanetary Cruise Campaign") # Configure settings related to hotel campaigns. c.advertising_channel_type = :HOTEL c.hotel_setting = client.resource.hotel_setting_info do |hsi| hsi.hotel_center_id = hotel_center_account_id end # Recommendation: Set the campaign to PAUSED when creating it to prevent the # ads from immediately serving. Set to ENABLED once you've added targeting and # the ads are ready to serve. c.status = :PAUSED # Set the bidding strategy to PercentCpc. Only Manual CPC and Percent CPC can # be used for hotel campaigns. c.percent_cpc = client.resource.percent_cpc do |pcpc| pcpc.cpc_bid_ceiling_micros = cpc_bid_ceiling_micro_amount end # Set the budget. c.campaign_budget = budget_resource # Configures the campaign network options. Only Google Search is allowed for # hotel campaigns. c.network_settings = client.resource.network_settings do |ns| ns.target_google_search = true end end # Issue a mutate request to add the campaign. campaign_service = client.service.campaign response = campaign_service.mutate_campaigns( customer_id: customer_id, operations: [campaign_operation], ) # Fetch the new campaign's resource name. campaign_resource = response.results.first.resource_name puts "Added hotel campaign with resource name '#{campaign_resource}'." campaign_resource end
Perl
sub add_hotel_campaign { my ($api_client, $customer_id, $budget_resource_name, $hotel_center_account_id, $cpc_bid_ceiling_micro_amount) = @_; # Create a hotel campaign. my $campaign = Google::Ads::GoogleAds::V18::Resources::Campaign->new({ name => "Interplanetary Cruise Campaign #" . uniqid(), # Configure settings related to hotel campaigns including advertising # channel type and hotel setting info. advertisingChannelType => HOTEL, hotelSetting => Google::Ads::GoogleAds::V18::Resources::HotelSettingInfo->new({ hotelCenterId => $hotel_center_account_id } ), # Recommendation: Set the campaign to PAUSED when creating it to prevent # the ads from immediately serving. Set to ENABLED once you've added # targeting and the ads are ready to serve. status => Google::Ads::GoogleAds::V18::Enums::CampaignStatusEnum::PAUSED, # Set the bidding strategy to PercentCpc. Only Manual CPC and Percent CPC # can be used for hotel campaigns. percentCpc => Google::Ads::GoogleAds::V18::Common::PercentCpc->new( {cpcBidCeilingMicros => $cpc_bid_ceiling_micro_amount} ), # Set the budget. campaignBudget => $budget_resource_name, # Configure the campaign network options. Only Google Search is allowed for # hotel campaigns. networkSettings => Google::Ads::GoogleAds::V18::Resources::NetworkSettings->new({ targetGoogleSearch => "true" })}); # Create a campaign operation. my $campaign_operation = Google::Ads::GoogleAds::V18::Services::CampaignService::CampaignOperation-> new({create => $campaign}); # Add the campaign. my $campaign_resource_name = $api_client->CampaignService()->mutate({ customerId => $customer_id, operations => [$campaign_operation]})->{results}[0]{resourceName}; printf "Added a hotel campaign with resource name: '%s'.\n", $campaign_resource_name; return $campaign_resource_name; }