实施推荐活动广告的第一步是制作推荐活动广告系列。在制作广告系列时,您需要设置其预算、出价策略和 Things to do Center 账号 ID。
设置广告系列的具体步骤如下:
- 将广告系列的
advertising_channel_type设置为TRAVEL,并将advertising_channel_sub_type设置为TRAVEL_ACTIVITIES。 - 创建
TravelCampaignSettings,设置其travel_account_id,然后将其添加到广告系列中。 - 为广告系列创建
MaximizeConversionValue出价策略。
以下代码演示了这些步骤。
Java
private String addThingsToDoCampaign( GoogleAdsClient googleAdsClient, long customerId, String budgetResourceName, long thingsToDoCenterAccountId) { // Creates the campaign. Campaign campaign = Campaign.newBuilder() .setName("Interplanetary Cruise #" + getPrintableDateTime()) // Configures settings related to Things to do campaigns including advertising channel // type, advertising channel sub type and travel campaign settings. .setAdvertisingChannelType(AdvertisingChannelType.TRAVEL) .setAdvertisingChannelSubType(AdvertisingChannelSubType.TRAVEL_ACTIVITIES) .setTravelCampaignSettings( TravelCampaignSettings.newBuilder().setTravelAccountId(thingsToDoCenterAccountId)) // Recommendation: Sets 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 .setStatus(CampaignStatus.PAUSED) // Sets the bidding strategy to MaximizeConversionValue. Only this type can be used // for Things to do campaigns. .setMaximizeConversionValue(MaximizeConversionValue.newBuilder()) // Sets the budget. .setCampaignBudget(budgetResourceName) // Configures the campaign network options. Only Google Search is allowed for // Things to do campaigns. .setNetworkSettings(NetworkSettings.newBuilder().setTargetGoogleSearch(true)) // Declares whether this campaign serves political ads targeting the EU. .setContainsEuPoliticalAdvertising(DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING) .build(); // Creates a campaign operation. CampaignOperation operation = CampaignOperation.newBuilder().setCreate(campaign).build(); // Issues a mutate request to add the campaign. try (CampaignServiceClient campaignServiceClient = googleAdsClient.getLatestVersion().createCampaignServiceClient()) { MutateCampaignsResponse response = campaignServiceClient.mutateCampaigns( Long.toString(customerId), Collections.singletonList(operation)); MutateCampaignResult result = response.getResults(0); System.out.printf( "Added a Things to do campaign with resource name: '%s'%n", result.getResourceName()); return result.getResourceName(); } }
C#
// Creates a campaign. Campaign campaign = new Campaign() { Name = "Interplanetary Cruise #" + ExampleUtilities.GetRandomString(), AdvertisingChannelType = AdvertisingChannelType.Travel, AdvertisingChannelSubType = AdvertisingChannelSubType.TravelActivities, TravelCampaignSettings = new TravelCampaignSettings() { TravelAccountId = thingsToDoCenterAccountId }, // 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, // Set the bidding strategy and budget. MaximizeConversionValue = new MaximizeConversionValue(), CampaignBudget = budget, // Set the campaign network options. NetworkSettings = new NetworkSettings { TargetGoogleSearch = true }, // Declare whether or not this campaign contains political ads targeting the EU. ContainsEuPoliticalAdvertising = EuPoliticalAdvertisingStatus.DoesNotContainEuPoliticalAdvertising, };
PHP
private static function addThingsToDoCampaign( GoogleAdsClient $googleAdsClient, int $customerId, string $budgetResourceName, int $thingsToDoCenterAccountId ) { // Creates a campaign. $campaign = new Campaign([ 'name' => 'Interplanetary Cruise Campaign #' . Helper::getPrintableDatetime(), // Configures settings related to Things to do campaigns including advertising channel // type, advertising channel sub type and travel campaign settings. 'advertising_channel_type' => AdvertisingChannelType::TRAVEL, 'advertising_channel_sub_type' => AdvertisingChannelSubType::TRAVEL_ACTIVITIES, 'travel_campaign_settings' => new TravelCampaignSettings(['travel_account_id' => $thingsToDoCenterAccountId]), // 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 MaximizeConversionValue. Only this type can be used // for Things to do campaigns. 'maximize_conversion_value' => new MaximizeConversionValue(), // Sets the budget. 'campaign_budget' => $budgetResourceName, // Configures the campaign network options. Only Google Search is allowed for // Things to do 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 Things to do campaign with resource name '%s'.%s", $addedCampaign->getResourceName(), PHP_EOL ); return $addedCampaign->getResourceName(); }