// Get AdWordsUser from "~/adwords.properties".
AdWordsUser user = new AdWordsUser();
// Get the AdGroupCriterionService.
AdGroupCriterionServiceInterface adGroupCriterionService =
user.getService(AdWordsService.V201306.ADGROUP_CRITERION_SERVICE);
long adGroupId = Long.parseLong("INSERT_AD_GROUP_ID_HERE");
// Create keyword.
Keyword keyword = new Keyword();
keyword.setText("mars cruise");
keyword.setMatchType(KeywordMatchType.BROAD);
// Create biddable ad group criterion.
BiddableAdGroupCriterion keywordBiddableAdGroupCriterion = new BiddableAdGroupCriterion();
keywordBiddableAdGroupCriterion.setAdGroupId(adGroupId);
keywordBiddableAdGroupCriterion.setCriterion(keyword);
// Create placement.
Placement placement = new Placement();
placement.setUrl("http://mars.google.com");
// Create biddable ad group criterion for placement.
BiddableAdGroupCriterion placementBiddableAdGroupCriterion = new BiddableAdGroupCriterion();
placementBiddableAdGroupCriterion.setAdGroupId(adGroupId);
placementBiddableAdGroupCriterion.setCriterion(placement);
// Create operations.
AdGroupCriterionOperation keywordAdGroupCriterionOperation = new AdGroupCriterionOperation();
keywordAdGroupCriterionOperation.setOperand(keywordBiddableAdGroupCriterion);
keywordAdGroupCriterionOperation.setOperator(Operator.ADD);
AdGroupCriterionOperation placementAdGroupCriterionOperation =
new AdGroupCriterionOperation();
placementAdGroupCriterionOperation.setOperand(placementBiddableAdGroupCriterion);
placementAdGroupCriterionOperation.setOperator(Operator.ADD);
AdGroupCriterionOperation[] operations =
new AdGroupCriterionOperation[] {keywordAdGroupCriterionOperation,
placementAdGroupCriterionOperation};
// Add ad group criteria.
AdGroupCriterionReturnValue result = adGroupCriterionService.mutate(operations);
// Display ad group criteria.
if (result != null && result.getValue() != null) {
for (AdGroupCriterion adGroupCriterionResult : result.getValue()) {
System.out.println("Ad group criterion with ad group id \""