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 ?

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/695e07a2-3ec1-4b34-92a6-57155b70d055n%40googlegroups.com.

Reply via email to