private static Campaign createCampaignWithBiddingStrategy ( AdWordsServicesInterface adWordsServices , AdWordsSession session , Long biddingStrategyId , Long sharedBudgetId ) throws RemoteException { // Get the CampaignService, which loads the required classes. CampaignServiceInterface campaignService = adWordsServices . get ( session , CampaignServiceInterface . class ) ; // Create campaign. Campaign campaign = new Campaign ( ) ; campaign . setName ( "Interplanetary Cruise #" + System . currentTimeMillis ( ) ) ; // 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 . setStatus ( CampaignStatus . PAUSED ) ; // Set the budget. Budget budget = new Budget ( ) ; budget . setBudgetId ( sharedBudgetId ) ; campaign . setBudget ( budget ) ; // Set bidding strategy (required). BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration ( ) ; biddingStrategyConfiguration . setBiddingStrategyId ( biddingStrategyId ) ; campaign . setBiddingStrategyConfiguration ( biddingStrategyConfiguration ) ; // Set advertising channel type (required). campaign . setAdvertisingChannelType ( AdvertisingChannelType . SEARCH ) ; // Set network targeting (recommended). NetworkSetting networkSetting = new NetworkSetting ( ) ; networkSetting . setTargetGoogleSearch ( true ) ; networkSetting . setTargetSearchNetwork ( true ) ; networkSetting . setTargetContentNetwork ( true ) ; campaign . setNetworkSetting ( networkSetting ) ; // Create operation. CampaignOperation operation = new CampaignOperation ( ) ; operation . setOperand ( campaign ) ; operation . setOperator ( Operator . ADD ) ; CampaignReturnValue result = campaignService . mutate ( new CampaignOperation [ ] { operation } ) ; Campaign newCampaign = result . getValue ( 0 ) ; System . out . printf ( "Campaign with name '%s', ID %d and bidding scheme ID %d was created.%n" , newCampaign . getName ( ) , newCampaign . getId ( ) , newCampaign . getBiddingStrategyConfiguration ( ) . getBiddingStrategyId ( ) ) ; return newCampaign ; }
Create a Campaign with a portfolio bidding strategy .