← 返回目录
来源:Google Ads API 官方文档 · 中文版 · 本地归档

制作酒店广告系列

植入酒店广告的第一步是制作酒店广告系列。在制作酒店广告系列时,您需要设置其预算、出价策略和 Hotel Ads Center 账号 ID。

设置酒店广告系列的具体步骤如下:

  1. 将广告系列的 advertising_channel_type 设置为 HOTEL。
  2. 创建 HotelSettingInfo,设置其 hotel_center_id,然后将其添加到广告系列中。
  3. 为该广告系列创建 PercentCpc 出价策略。如需详细了解出价策略和出价设置,请参阅出价概览。

以下代码演示了这些步骤。

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,
        ]),
        // Declare whether or not this campaign serves political ads targeting the EU.
        'contains_eu_political_advertising' =>
            EuPoliticalAdvertisingStatus::DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
    ]);

    // 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();
}
在接这个接口时卡住了?
Stuck wiring this API into production? We build ad-delivery tooling on these platforms — campaign automation, reporting pipelines, error-handling and migration between API versions.
联系我们 · Talk to us 每日平台更新简报 →