Set TargetingSettingDetail on BiddableAdGroupCriterion

82 views
Skip to first unread message

rafa....@rocketroi.com

unread,
Aug 14, 2017, 11:56:44 AM8/14/17
to AdWords API Forum
Hi all,

i'm wondering how to add TargetingSettingDetail on BiddableAdGroupCriterion while creating AdGroup Criterion (Segmentation).

This is how I create the AdGroupCriterion:

def adwordsServices = new AdWordsServices()
def adGroupCriterionService = adwordsServices.get(session, AdGroupCriterionServiceInterface.class)

def criterion = new CriterionUserList()
criterion.setUserListId(userListId)
criterion.setUserListName(userListName)
criterion.setUserListMembershipStatus(CriterionUserListMembershipStatus.fromValue(userListStatus))

def bidCriterion = new BiddableAdGroupCriterion()
bidCriterion.setAdGroupId(adGroupId)
bidCriterion.setCriterion(criterion)
bidCriterion.setUserStatus(new UserStatus(status))

// Create operations.
def operation = new AdGroupCriterionOperation()
operation.setOperand(bidCriterion)
operation.setOperator(Operator.ADD)

def operations = (AdGroupCriterionOperation[]) [operation]

// Update ad group criteria.
def result = adGroupCriterionService.mutate(operations)

And this the way I build the TargetingSettingDetail

TargetingSettingDetail userTargetDetail = new TargetingSettingDetail();
userTargetDetail.criterionTypeGroup = CriterionTypeGroup.USER_INTEREST_AND_LIST;
userTargetDetail.targetAll = "BOTH".equals(type) ? false : true;

TargetingSetting targetingSetting = new TargetingSetting();
targetingSetting.details = (TargetingSettingDetail[]) [userTargetDetail]

But I don't know how to relate to each other. I'm trying to run the operation both to CampaignCriterion and AdGroupCriterion. In CampaignCriterion instead of BiddableAdGroupCriterion we use CampaignCriterion

Thank you for the help!

Shwetha Vastrad (AdWords API Team)

unread,
Aug 14, 2017, 2:19:21 PM8/14/17
to AdWords API Forum
Hi, 

You need to set the TargetingSettingDetail at the Campaign or AdGroup level using CampaignService or AdGroupService respectively. The TargetingSettingDetail will specify if a particular criteria type will be used to restrict targeting or only be used to determine the bid for this Campaign or Ad Group. This guide shows how Ads will serve based on different targeting combinations. The AddAdGroups Java example shows how to add targeting restrictions at the AdGroup level for PLACEMENT and VERTICAL criteria. You can perform a similar operation for USER_INTEREST_AND_LIST criteria type group. 

Regards,
Shwetha, AdWords API Team.

rafa....@rocketroi.com

unread,
Aug 16, 2017, 5:08:53 AM8/16/17
to AdWords API Forum
It works!

Thank you Shwetha!
Reply all
Reply to author
Forward
0 new messages