Platform Criteria to Campaign

23 views
Skip to first unread message

Aekansh Partani

unread,
Dec 17, 2019, 11:24:14 PM12/17/19
to AdWords API and Google Ads API Forum
I am using AdwordsAPI 

Error:
[CampaignCriterionError.CANNOT_EXCLUDE_CRITERIA_TYPE @ operations[0].operand.criterion; trigger:'PLATFORM']


Code I am Trying with : 

$campaign_id = "";
$campaignService = $adWordsServices->get(sessionBuilder(), CampaignService::class);
$campaignCriterionService = $adWordsServices->get(sessionBuilder(), CampaignCriterionService::class);
// Create a campaign
$campaign = new Campaign();
$campaign->setName("New Campaign".' #' . uniqid()); //Set Campaign Name
$campaign->setAdvertisingChannelType(AdvertisingChannelType::DISPLAY);

//Budget Start
$budgetService = $adWordsServices->get(sessionBuilder(), BudgetService::class);
$budget = new Budget();
$budget->setName(' Budget #' . uniqid());
$budget->setIsExplicitlyShared(false);
$money = new Money();
$money->setMicroAmount((int)(500* 1000000));
$budget->setAmount($money);
$budget->setDeliveryMethod(BudgetBudgetDeliveryMethod::STANDARD);
$operations = [];
// Create a budget operation.
$operation = new BudgetOperation();
$operation->setOperand($budget);
$operation->setOperator(Operator::ADD);
$operations[] = $operation;
// Create the budget on the server.
$result = $budgetService->mutate($operations);
$budget = $result->getValue()[0];
//Budget End

// Set Budget to campaign
$campaign->setBudget(new Budget());
$campaign->getBudget()->setBudgetId($budget->getBudgetId());

// Bidding Strategy
$biddingStrategyConfiguration = new BiddingStrategyConfiguration();
$biddingStrategyConfiguration->setBiddingStrategyType(BiddingStrategyType::MANUAL_CPM);
$campaign->setBiddingStrategyConfiguration($biddingStrategyConfiguration);

//Pause Campaign
$campaign->setStatus(CampaignStatus::PAUSED);

// Create a campaign operation and add it to the operations list.
$operations = [];
$operation = new CampaignOperation();
$operation->setOperand($campaign);
$operation->setOperator(Operator::ADD);
$operations[] = $operation;
// Create the campaigns on the server
$resultCampaign = $campaignService->mutate($operations)->getValue()[0];
$campaign_id = $resultCampaign->getId();

$platform = new \Google\AdsApi\AdWords\v201809\cm\Platform();
$platform->setId('30002');

$criterion = new NegativeCampaignCriterion();
$criterion->setCampaignId($campaign_id);
$criterion->setCriterion($platform);

// Create a campaign criterion operation and add it to the operations list.
$operation = new CampaignCriterionOperation();
$operation->setOperator(Operator::ADD);
$operation->setOperand($criterion);
$operations = [$operation];
// Update campaign criteria on the server.
$results = $campaignCriterionService->mutate($operations);

return $result;

Google Ads API Forum Advisor Prod

unread,
Dec 18, 2019, 11:00:07 AM12/18/19
to aekansh...@gmail.com, adwor...@googlegroups.com
Hi Aekansh,

It is not possible to exclude platform criteria at both the API and UI level. You can only adjust the bid modifiers for these criteria. You can refer to this chart to see what can be targeted and excluded at either the campaign or ad group level.

Regards,
Anthony
Google Ads API Team

ref:_00D1U1174p._5001UOEnlE:ref
Reply all
Reply to author
Forward
0 new messages