private static AdGroup createAdGroup ( AdWordsServicesInterface adWordsServices , AdWordsSession session , Campaign campaign ) throws ApiException , RemoteException { // Get the AdGroupService. AdGroupServiceInterface adGroupService = adWordsServices . get ( session , AdGroupServiceInterface . class ) ; // Create the ad group. AdGroup adGroup = new AdGroup ( ) ; // Required: Set the ad group's type to Dynamic Search Ads. adGroup . setAdGroupType ( AdGroupType . SEARCH_DYNAMIC_ADS ) ; adGroup . setName ( "Earth to Mars Cruises #" + System . currentTimeMillis ( ) ) ; adGroup . setCampaignId ( campaign . getId ( ) ) ; adGroup . setStatus ( AdGroupStatus . PAUSED ) ; // Recommended: Set a tracking URL template for your ad group if you want to use URL // tracking software. adGroup . setTrackingUrlTemplate ( "http://tracker.example.com/traveltracker/{escapedlpurl}" ) ; // Set the ad group bids. BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration ( ) ; CpcBid cpcBid = new CpcBid ( ) ; cpcBid . setBid ( new Money ( ) ) ; cpcBid . getBid ( ) . setMicroAmount ( 3000000L ) ; biddingConfig . setBids ( new Bids [ ] { cpcBid } ) ; adGroup . setBiddingStrategyConfiguration ( biddingConfig ) ; // Create the operation. AdGroupOperation operation = new AdGroupOperation ( ) ; operation . setOperand ( adGroup ) ; operation . setOperator ( Operator . ADD ) ; AdGroup newAdGroup = adGroupService . mutate ( new AdGroupOperation [ ] { operation } ) . getValue ( 0 ) ; System . out . printf ( "Ad group with name '%s' and ID %d was added.%n" , newAdGroup . getName ( ) , newAdGroup . getId ( ) ) ; return newAdGroup ; }
Creates the ad group .