How can I bid for keywords with googleads-php-lib?

45 views
Skip to first unread message

Dmitry

unread,
Sep 2, 2019, 11:28:24 PM9/2/19
to AdWords API and Google Ads API Forum
Using ReportDefinition (KEYWORDS_PERFORMANCE_REPORT) I get FirstPageCpc and keywordId

            $selector = new Selector();
            $selector->setFields(["Id", "AdGroupId", "AdGroupName", "Criteria", "AbsoluteTopImpressionPercentage", "Impressions", "Ctr", "AveragePosition", "FirstPositionCpc", "TopOfPageCpc", "FirstPageCpc"]);
           
            // Create report definition.
            $reportDefinition = new ReportDefinition();
            $reportDefinition->setSelector($selector);
            $reportDefinition->setReportName(
                'Criteria performance report #' . uniqid()
            );
            $reportDefinition->setDateRangeType(
                ReportDefinitionDateRangeType::LAST_7_DAYS
            );
            $reportDefinition->setReportType(
                ReportDefinitionReportType::KEYWORDS_PERFORMANCE_REPORT
            );
            $reportDefinition->setDownloadFormat(DownloadFormat::CSV);

How can I bid (FirstPageCpc) for keywordid with googleads-php-lib? Thx.


Google Ads API Forum Advisor Prod

unread,
Sep 3, 2019, 2:22:04 AM9/3/19
to adwor...@googlegroups.com
Hi Dmitry,

Thank you for reaching out.

Could you confirm if my understanding is correct that you would like to know how to set your bid on your CpcBid based on the value you retrieved from the FirstPageCpc field? If this is what you meant, you may use the AdGroupCriterionService.mutate() or AdGroupService.mutate() to set the bid on a criterion level or ad group level respectively. You must set the bid of the BiddingStrategyConfiguration to CpcBid. You may refer to this guide for more details and samples.

Regards,
Dannison
Google Ads API Team

ref:_00D1U1174p._5001UHFS8N:ref

Dmitry

unread,
Sep 3, 2019, 6:00:22 AM9/3/19
to AdWords API and Google Ads API Forum
Does this set the bet on the Ad Group (by AdGroupId)? I need to bet on every keyword by keywordID. Can I do that?

вторник, 3 сентября 2019 г., 9:22:04 UTC+3 пользователь adsapiforumadvisor написал:

Google Ads API Forum Advisor Prod

unread,
Sep 4, 2019, 2:14:29 AM9/4/19
to adwor...@googlegroups.com
Hi Dmitry,

Yes, the AdGroupService.mutate() sets bid on an ad group level. You can also set bids on keywords individually using the AdGroupCriterionService.mutate(). You can refer to this sample code (also available in different languages) on how to add keywords with bids.

Dmitry

unread,
Sep 4, 2019, 8:11:44 AM9/4/19
to AdWords API and Google Ads API Forum
I was able to add a new keyword with a new bet to the group.

$keyword = new Keyword();
$keyword
->setText('TEST WORD');
$keyword
->setMatchType(KeywordMatchType::BROAD);

But how do I change the bet of an existing keyword by knowing keywordID?

It does not work:
$keywordID = 1234567890;
$keyword
= new Keyword($keywordID);






среда, 4 сентября 2019 г., 9:14:29 UTC+3 пользователь adsapiforumadvisor написал:

Dmitry

unread,
Sep 4, 2019, 8:40:21 AM9/4/19
to AdWords API and Google Ads API Forum
Problem resolved, I changed
$operation- >setOperator (Operator: ADD);
=>
$operation- >setOperator (Operator: SET);

Thx.

среда, 4 сентября 2019 г., 9:14:29 UTC+3 пользователь adsapiforumadvisor написал:
Hi Dmitry,

Google Ads API Forum Advisor Prod

unread,
Sep 5, 2019, 1:27:13 AM9/5/19
to adwor...@googlegroups.com
Hi Dmitry,

Glad you have fixed your issue. Let me know if you have further concerns regarding the AdWords API.
Reply all
Reply to author
Forward
0 new messages