Not able to set cpc limit using google adwords api

38 views
Skip to first unread message

Asif Saeed

unread,
Mar 18, 2020, 11:36:07 AM3/18/20
to AdWords API and Google Ads API Forum
I have created google adCampaigns, adGroups, Keywords, Ads, Locations using Google Adwords API but I am not able to set "Set a maximum cost per click bid limit" using API

Screenshot 2020-03-18 at 6.27.19 PM.png


Google Ads API Forum Advisor Prod

unread,
Mar 18, 2020, 4:04:48 PM3/18/20
to asif....@vizteck.com, adwor...@googlegroups.com
Hi Asif,

Thank you for reaching out. You can use the CampaignService to set the CpcBid of your campaign. This is the maximum cost per click value.

Regards,
Mitchell
Google Ads API Team

ref:_00D1U1174p._5001UXVQyv:ref

Asif Saeed

unread,
Mar 19, 2020, 2:28:52 AM3/19/20
to Google Ads API Forum Advisor Prod, adwor...@googlegroups.com
Hi, 
Thanks for the reply.
I am adding bid like this in CampaignService 


        $campaign->setAdvertisingChannelType(AdvertisingChannelType::SEARCH);

        // Set shared budget (required).
        $campaign->setBudget(new Budget());
        $campaign->getBudget()->setBudgetId($budget->getBudgetId());
        $biddingStrategyConfiguration = new BiddingStrategyConfiguration();
        $biddingStrategyConfiguration->setBiddingStrategyType(
            BiddingStrategyType::TARGET_SPEND
        );

        // You can optionally provide a bidding scheme in place of the type.
        $biddingScheme = new TargetSpendBiddingScheme();
        $biddingScheme->setBidCeiling($_GET['cpc'] * 1000000);
        $biddingScheme->setSpendTarget($_GET['cpc'] * 1000000);
    
        $bid = new CpcBid();
        $money = new Money();
        $money->setMicroAmount($_GET['cpc'] * 1000000);
        $bid->setBid($money);
        $biddingStrategyConfiguration = new BiddingStrategyConfiguration();
        $biddingStrategyConfiguration->setBids([$bid]);

        $biddingStrategyConfiguration->setBiddingScheme($biddingScheme);

        $campaign->setBiddingStrategyConfiguration($biddingStrategyConfiguration); but this now throws an error

PHP Fatal error:  Uncaught Google\\AdsApi\\AdWords\\v201809\\cm\\ApiException: [OperationAccessDenied.OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE @ operations[0].operand.biddingStrategyConfiguration.bids; trigger:'SEARCH']



--
Regards
Asif Saeed

Software Engineer

Skype : a.saeed.vm




Google Ads API Forum Advisor Prod

unread,
Mar 19, 2020, 1:01:07 PM3/19/20
to asif....@vizteck.com, adwor...@googlegroups.com
Hi Asif,

Can you please provide the complete detailed request and response logs for the call via Reply privately to author so that I can further investigate the issue? You can find more information on enabling logging here (log level NOTICE).

Is this an already existing campaign that you are trying to modify or is it a brand new campaign?
Reply all
Reply to author
Forward
0 new messages