Cannot set total budget on campaign level

110 views
Skip to first unread message

vino...@skills-agency.com

unread,
Mar 15, 2022, 2:26:40 AM3/15/22
to Google Ads API and AdWords API Forum
Hi,

I'm trying to set bidding strategy as Maximize clicks and budget for whole campaign. 
Below is my code to create a campaign :

$budgetResourceName = $this->addCampaignBudget(10000.36);

// Creates a campaign.
$campaign = new Campaign([
'name' => 'THIL_DISPLAY',
'advertising_channel_type' => AdvertisingChannelType::DISPLAY,
'status' => CampaignStatus::PAUSED,

'campaign_budget' => $budgetResourceName,

// Sets the standard bidding strategy and budget.
'target_spend' => new TargetSpend(
['cpc_bid_ceiling_micros' => $camp_data['budget'] * 1000000]
),

// Optional: Sets the start and end dates.
'start_date' => date('Ymd', strtotime($camp_data['start_date'])),
'end_date' => date('Ymd', strtotime($camp_data['end_date']))
]);

// Creates a campaign operation.
$campaignOperation = new CampaignOperation();
$campaignOperation->setCreate($campaign);

$campaignServiceClient = $this->googleAdsClient->getCampaignServiceClient();
$campaignResponse = $campaignServiceClient->mutateCampaigns($this->CUSTOMER_ID, [$campaignOperation]);
$campaignResourceName = $campaignResponse->getResults()[0]->getResourceName();
return $campaignResourceName;

public function addCampaignBudget($budget) {
$budget = new CampaignBudget([
'name' => 'Budget #'.$budget_name,
'delivery_method' => BudgetDeliveryMethod::STANDARD,
// 'amount_micros' => $budget * 1000000, //*1000000
'total_amount_micros' => 1000000, //*1000000
'period' => BudgetPeriod::CUSTOM_PERIOD,
'explicitly_shared' => false
]);

$campaignBudgetOperation = new CampaignBudgetOperation();
$campaignBudgetOperation->setCreate($budget);

$campaignBudgetServiceClient = $this->googleAdsClient->getCampaignBudgetServiceClient();
$response = $campaignBudgetServiceClient->mutateCampaignBudgets(
$this->CUSTOMER_ID,
[$campaignBudgetOperation]
);

$addedBudget = $response->getResults()[0];
return $addedBudget->getResourceName();
}

When i set amount_micros (without total_amount_micros & period) then the campaign budget is setting up as daily budget.
So i set total_amount_micros & period then i'm getting error like OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE.
Also i tried to set amount_micros & period then im getting error like below :

{ "message": "Request contains an invalid argument.", "code": 3, "status": "INVALID_ARGUMENT", "details": [ { "@type": 0, "data": "type.googleapis.com\/google.ads.googleads.v8.errors.GoogleAdsFailure" }, { "@type": 0, "data": [ { "errorCode": { "requestError": "UNKNOWN" }, "message": "The error code is not in this version.", "trigger": { "int64Value": "10000360000" }, "location": { "fieldPathElements": [ { "fieldName": "operations", "index": 0 }, { "fieldName": "create" }, { "fieldName": "amount_micros" } ] } } ] }, { "@type": 0, "data": "wxH3aLWrIaZcf1gOHCyx4w" } ] }


When i see in UI daily budget field is not mandatory and i could set bidding strategy. But through api campaign daily budget seems to be mandatory because i tried to set bidding strategy in campaign level and i have set cpc_bid_ceiling_micros but im getting error showing that The required field was not present. camapign_budget .

How can i set campaign whole budget ?

Google Ads API Forum Advisor

unread,
Mar 15, 2022, 3:40:08 AM3/15/22
to vino...@skills-agency.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to our API support team and for the details you included.

However, regarding the The error code is not in this version detail from the error, and so our team can further investigate, could you try using the latest version and provide to our team the complete request and response logs, and the request-id

You may then send the requested information via the Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead.

Best regards,

Google Logo
Peter Laurence
Google Ads API Team
 


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