Hi,
To add a
specific gender and age ad group criterion to an ad group, you can refer to
this example. The example shows how to add gender as a biddable ad group criterion and age range as a negative criterion; however you can use the following code snippet to ad age range as a biddable ad group criterion as well:
AgeRange a18to24 = new AgeRange();
a18to24.setId(503001L);
BiddableAdGroupCriterion ageBiddableAdGroupCriterion = new BiddableAdGroupCriterion();
ageBiddableAdGroupCriterion.setAdGroupId(adGroupId);
ageBiddableAdGroupCriterion.setCriterion(a18to24);
Please note that an ad group ID is required in the
setAdGroupId() method for you to be able to target an ad group. If you plan to reuse the
ageBiddableAdGroupCriterion object, you can initially set the criterion on the object using
setCriterion() method and set the ad group ID at the time of the
creation of the operation.
Although, AgeRange and Gender can be used as targeting criteria on an ad group, I would suggest referring to the
Criteria Usage Guide to check if you are allowed to use a particular criteria on your ad group type (search, display, SNDS etc). A complete list of codes for gender and age range targeting is available on
this page.
Please let me know if you have further questions.