private static void createPerformanceTarget ( AdWordsServicesInterface adWordsServices , AdWordsSession session , CampaignGroup campaignGroup ) throws ApiException , RemoteException { // Get the CampaignGroupPerformanceTargetService. CampaignGroupPerformanceTargetServiceInterface campaignGroupPerformanceTargetService = adWordsServices . get ( session , CampaignGroupPerformanceTargetServiceInterface . class ) ; // Create the performance target. CampaignGroupPerformanceTarget campaignGroupPerformanceTarget = new CampaignGroupPerformanceTarget ( ) ; campaignGroupPerformanceTarget . setCampaignGroupId ( campaignGroup . getId ( ) ) ; PerformanceTarget performanceTarget = new PerformanceTarget ( ) ; // Keep the CPC for the campaigns < $3. performanceTarget . setEfficiencyTargetType ( EfficiencyTargetType . CPC_LESS_THAN_OR_EQUAL_TO ) ; performanceTarget . setEfficiencyTargetValue ( 3000000d ) ; // Keep the maximum spend under $50. performanceTarget . setSpendTargetType ( SpendTargetType . MAXIMUM ) ; Money maxSpend = new Money ( ) ; maxSpend . setMicroAmount ( 500000000L ) ; performanceTarget . setSpendTarget ( maxSpend ) ; // Aim for at least 3000 clicks. performanceTarget . setVolumeTargetValue ( 3000L ) ; performanceTarget . setVolumeGoalType ( VolumeGoalType . MAXIMIZE_CLICKS ) ; // Start the performance target today, and run it for the next 90 days. DateTime startDate = DateTime . now ( ) ; DateTime endDate = DateTime . now ( ) . plusDays ( 90 ) ; performanceTarget . setStartDate ( startDate . toString ( "yyyyMMdd" ) ) ; performanceTarget . setEndDate ( endDate . toString ( "yyyyMMdd" ) ) ; campaignGroupPerformanceTarget . setPerformanceTarget ( performanceTarget ) ; // Create the operation. CampaignGroupPerformanceTargetOperation operation = new CampaignGroupPerformanceTargetOperation ( ) ; operation . setOperand ( campaignGroupPerformanceTarget ) ; operation . setOperator ( Operator . ADD ) ; CampaignGroupPerformanceTarget newCampaignGroupPerformanceTarget = campaignGroupPerformanceTargetService . mutate ( new CampaignGroupPerformanceTargetOperation [ ] { operation } ) . getValue ( 0 ) ; // Display the results. System . out . printf ( "Campaign group performance target with ID %d was added for campaign group ID %d.%n" , newCampaignGroupPerformanceTarget . getId ( ) , newCampaignGroupPerformanceTarget . getCampaignGroupId ( ) ) ; }
Creates a performance target for the campaign group .