호텔 캠페인 만들기

호텔 광고를 구현하는 첫 번째 단계는 호텔 캠페인을 만드는 것입니다. 포함 예산, 입찰 전략, 호텔 광고를 설정하기 위해 센터 계정 ID

호텔 캠페인을 설정하는 단계는 다음과 같습니다.

  1. 캠페인의 advertising_channel_type을(를) 다음으로 설정 HOTEL
  2. HotelSettingInfo 생성, 설정 hotel_center_id, 캠페인에 추가합니다.
  3. 다음에 대한 PercentCpc 입찰 전략을 만드는 중: 확인할 수 있습니다. 입찰 전략 및 입찰가 설정에 대한 자세한 내용은 다음을 참고하세요. 입찰 개요

이러한 단계는 다음 코드에 나와 있습니다.

자바

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::V17::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::V17::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::V17::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::V17::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::V17::Resources::NetworkSettings->new({
          targetGoogleSearch => "true"
        })});

  # Create a campaign operation.
  my $campaign_operation =
    Google::Ads::GoogleAds::V17::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;
}