Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I decrease mobile bid criteria for campaigns for Google AdWords API?

When I set the platform bid criteria to 0, it gives me an error:

Exception 'SoapFault' with message '[OperatorError.OPERATOR_NOT_SUPPORTED @ operations[2].operand.criterion; trigger:'CriterionId{id=30001}']'

// Mobile criterion ID.
$mobileCriterionId = 30001;
$platform = new Platform();
$platform->id = $mobileCriterionId;

$operations = array();
foreach ([$location, $language, $platform] as $criterion) {
  // create criteria
  $campaignCriterion = new CampaignCriterion();
  $campaignCriterion->campaignId = $campaign->id;
  $campaignCriterion->criterion = $criterion;

  if ($criterion == $platform) 
    $campaignCriterion->bidModifier = 0;

  // create operations to perform
  $operation = new CampaignCriterionOperation();
  $operation->operand = $campaignCriterion;
  $operation->operator = 'ADD';
  $operations[] = $operation;
}

// carry out the operations
$result = $campaignCriterionService->mutate($operations);    

Platforms: https://developers.google.com/adwords/api/docs/appendix/platforms

Criteria usage matrix: https://developers.google.com/adwords/api/docs/guides/criteria-usage

Example (for AdGroups): https://developers.google.com/adwords/api/docs/guides/adgroup-bid-modifiers#update

CampaignCriterion: https://developers.google.com/adwords/api/docs/reference/v201502/CampaignCriterionService.CampaignCriterion

Version: v201502, test account

like image 542
Chloe Avatar asked Dec 21 '25 21:12

Chloe


1 Answers

I had to use a 'SET' instead of 'ADD' operation, but only for Platform. Obvious, eh?

  if ($criterion == $platform)
    $operation->operator = 'SET'; # all platforms automatically added to new campaigns. cannot re-ad. must set. 
like image 192
Chloe Avatar answered Dec 23 '25 12:12

Chloe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!