System.out.println("Ad group with name \"" + adGroup.getName() + "\" and id \""
+ adGroup.getId() + "\" was updated for the experiment.");
// Set ad group criterion for the experiment.
BiddableAdGroupCriterion adGroupCriterion = new BiddableAdGroupCriterion();
adGroupCriterion.setCriterion(new Criterion(criterionId, null, null));
adGroupCriterion.setAdGroupId(adGroupId);
// Create experiment bid multiplier rule that will modify ad group bid for
// the experiment.
ManualCPCAdGroupCriterionExperimentBidMultiplier adGroupCriterionExperimentBidMultiplier =
new ManualCPCAdGroupCriterionExperimentBidMultiplier();
adGroupCriterionExperimentBidMultiplier.setMaxCpcMultiplier(new BidMultiplier(1.5, null));
// Set experiment data to the ad group.
BiddableAdGroupCriterionExperimentData adGroupCriterionExperimentData =
new BiddableAdGroupCriterionExperimentData();
adGroupCriterionExperimentData.setExperimentId(experimentId);
adGroupCriterionExperimentData.setExperimentDeltaStatus(ExperimentDeltaStatus.MODIFIED);
adGroupCriterionExperimentData
.setExperimentBidMultiplier(adGroupCriterionExperimentBidMultiplier);
adGroupCriterion.setExperimentData(adGroupCriterionExperimentData);
// Create operation.
AdGroupCriterionOperation adGroupCriterionOperation = new AdGroupCriterionOperation();
adGroupCriterionOperation.setOperand(adGroupCriterion);
adGroupCriterionOperation.setOperator(Operator.SET);
// Update ad group criterion.
adGroupCriterion =
(BiddableAdGroupCriterion) adGroupCriterionService.mutate(
new AdGroupCriterionOperation[] {adGroupCriterionOperation}).getValue()[0];
System.out.println("Ad group criterion with ad group id \"" + adGroupCriterion.getAdGroupId()
+ "\" and criterion id \"" + adGroupCriterion.getCriterion().getId()
+ "\" was updated for the experiment.");
} catch (Exception e) {
e.printStackTrace();
}
}