问题
I've been researching this for a few hours now and still can't figure out a solution.
I intend to exclude some content_labels on the campaign level. At first, I followed the API examples but those are for 'CustomerNegativeCriteria' that are account level settings (sidenote, I couldn't find these global settings on the AdWords interface).
Then I read more and tried to exclude them using a CampaignCriterion
So I'll create my ContentLabel objects in this way:
$criterion = new ContentLabel();
$criterion->setContentLabelType($sLabelType);
$criterion->setType(CriterionType::CONTENT_LABEL);
Then, I will add that modifier to a CampaignCriterion object:
foreach ($aModifiers as $modifier) {
$campaignCriterion = new CampaignCriterion($sCampaignId, $isNegative, $modifier, $bidModifier);
$operation = new CampaignCriterionOperation();
$operation->setOperand($campaignCriterion);
$operation->setOperator($operator);
$operations[] = $operation;
}
And then I'll pass those operations to a CampaignCriterionService
$oCampaignCriterionService = $this->getCampaignCriterionService();
return $oCampaignCriterionService->mutate($operations);
All this is generating this error but I can't find how to solve this. because in the campaign created those values are still in Green (active)
Message: [
CriterionError.CANNOT_TARGET_CRITERION @ operations[0].operand.criterion.contentLabelType; trigger:'DP',
CriterionError.CANNOT_TARGET_CRITERION @ operations[1].operand.criterion.contentLabelType; trigger:'ADULTISH',
CriterionError.CANNOT_TARGET_CRITERION @ operations[2].operand.criterion.contentLabelType; trigger:'JACKASS',
CriterionError.CANNOT_TARGET_CRITERION @ operations[3].operand.criterion.contentLabelType; trigger:'PROFANITY',
CriterionError.CANNOT_TARGET_CRITERION @ operations[4].operand.criterion.contentLabelType; trigger:'TRAGEDY',
CriterionError.CANNOT_TARGET_CRITERION @ operations[5].operand.criterion.contentLabelType; trigger:'VIDEO_RATING_DV_MA'
]
I'm following the tree structure from here but to no avail: https://developers.google.com/adwords/api/docs/reference/v201710/CampaignCriterionService.ContentLabel?hl=th
Any idea of what I could be doing wrong?
回答1:
The problem here was that I was creating CampaignCriterion
objects and that was the problem, although not explicitly stated anywhere, and not intuitive, there is another type of object called NegativeCampaignCriterion
and that is the right object to exclude ContentLabel
's and Placement
's
foreach ($aModifiers as $modifier) {
if ($isNegative) {
$campaignCriterion = new NegativeCampaignCriterion($sCampaignId, $isNegative, $modifier, $bidModifier);
} else {
$campaignCriterion = new CampaignCriterion($sCampaignId, $isNegative, $modifier, $bidModifier);
}
$operation = new CampaignCriterionOperation();
$operation->setOperand($campaignCriterion);
$operation->setOperator($operator);
$operations[] = $operation;
}
来源:https://stackoverflow.com/questions/47798493/adwords-api-exclude-content-label-on-campaign-level