Java max CPCBID from adgroupID and criterionID

22 views
Skip to first unread message

Thomas Bisballe

unread,
Feb 5, 2019, 6:41:13 AM2/5/19
to AdWords API and Google Ads API Forum
Is there a service i can call with adgroupID and criterionID in java
and get the last cpcbid.

When i use reports to get last bids (that otherwise works fine). They seem to not support things with low or no impressions/clicks. Even when i include zero impressions.

googleadsapi...@google.com

unread,
Feb 5, 2019, 3:02:09 PM2/5/19
to AdWords API and Google Ads API Forum
Hello Thomas,

To get the CpcBid of an AdGroup, you can use AdGroupService.get API call. You will need to set the CpcBid in the selector, please refer to this Java code. If you would like to get the CpcBid of the criterion, you can use the AdGroupCriterionService.get API call.

Thanks,
Milind, AdWords API Team
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

Thomas Bisballe

unread,
Feb 5, 2019, 4:43:16 PM2/5/19
to AdWords API and Google Ads API Forum
I'm only interested in the criterion cpc bid
With italics/bold i marked the nonexcisting functions in the api
But the data of the type is there in the data structure when i debug
but for some reason they're not accessible.
Is there any other way to get it?

The code i would like to write is:

    int offset = 0;
    boolean morePages = true;
    // Create selector.
    SelectorBuilder builder = new SelectorBuilder();
    Selector selector = builder
        .fields(
        AdGroupCriterionField.AdGroupId,
            AdGroupCriterionField.Id,
            AdGroupCriterionField.Status,
            AdGroupCriterionField.CpcBid)
        .offset(offset)
        .limit(PAGE_SIZE)
        .in(AdGroupCriterionField.AdGroupId, adGroupId.toString())
        .in(AdGroupCriterionField.Id, CriterionId.toString())
        .build();

    while (morePages) {
      // Get all ad group criteria.
      AdGroupCriterionPage page = adGroupCriterionService.get(selector);

      if (page.getEntries() != null && page.getEntries().length > 0) {
  for (AdGroupCriterion adGroupCriterionResult : page.getEntries()){
BiddingStrategyConfiguration bsc = adGroupCriterionResult.getBiddingStrategyConfiguration;
long oldbid = bsc.getBids(0).getBid.getMicroAmout;
System.out.print("Old bid was : "+oldbid);
}      
      } else {
        System.out.println("No ad group criteria were found.");
      }

// Display ad group criteria.
      offset += PAGE_SIZE;
      selector = builder.increaseOffsetBy(PAGE_SIZE).build();
      morePages = offset < page.getTotalNumEntries();

googleadsapi...@google.com

unread,
Feb 6, 2019, 1:08:19 PM2/6/19
to AdWords API and Google Ads API Forum
Hello,

Could you please retry with code snippet below:

BiddableAdGroupCriterion biddableAdGroupCriterion = new BiddableAdGroupCriterion();

biddableAdGroupCriterion = (BiddableAdGroupCriterion) adGroupCriterionResult; 
BiddingStrategyConfiguration bsc = biddableAdGroupCriterion.getBiddingStrategyConfiguration();

CpcBid cpcbid = (CpcBid) bsc.getBids(0);
Money money = cpcbid.getBid();
Long amount = money.getMicroAmount();
System.out.println("Amount : "+amount);

Let me know if you have any further questions. 


Thanks,
Milind, AdWords API Team
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Reply all
Reply to author
Forward
0 new messages