How do you get the configured tCPA from a portfolio bid strategy via scripts?

185 views
Skip to first unread message

Ben

unread,
Oct 12, 2022, 12:38:35 PM10/12/22
to Google Ads Scripts Forum
Using Google Ads Scripts, Is there anyway to get the target_CPA and CpcBidCeiling (Max CPC) from a target_CPA portfolio bid strategy ?

I just want to report what the values are, i dont need to change, create or set anything. 

I can do 
campaigns.bidding.getStrategy to get the portfolio bid strategy but i cant seem to access the elements of the portfolio bid strategy?

Thanks  

Nils Rooijmans

unread,
Oct 13, 2022, 3:04:02 AM10/13/22
to Google Ads Scripts Forum
You can probably use a GAQL query to request the values. Here's an example:

function main() {

  var gaqlQuery = "SELECT accessible_bidding_strategy.id, accessible_bidding_strategy.name, accessible_bidding_strategy.target_cpa.target_cpa_micros, accessible_bidding_strategy.target_spend.cpc_bid_ceiling_micros FROM accessible_bidding_strategy";
  Logger.log("gaqlQuery = "+gaqlQuery);  

  Logger.log("report via AdsApp.search method: ");
 
  var searchRowIterator = AdsApp.search(gaqlQuery);
   
  while (searchRowIterator.hasNext()) {
   var searchRow = searchRowIterator.next();
    logObject(searchRow);
  }

 
  Logger.log("report via AdsApp.report method: ");
 
  var report = AdsApp.report(gaqlQuery);
  var reportRowIterator = report.rows();
   
  while (reportRowIterator.hasNext()) {
   var reportRow = reportRowIterator.next();
    logObject(reportRow);
  }  
 
}


function logObject(objectString) {
  var output = JSON.stringify(objectString, null, 2);
  Logger.log(output);
}


Hope this helps,

Nils Rooijmans
https://nilsrooijmans.com
See my Google Ads Scripts FAQ to avoid the same mistakes I made: https://nilsrooijmans.com/google-ads-scripts-faq/

Ben

unread,
Oct 13, 2022, 4:50:01 AM10/13/22
to Google Ads Scripts Forum
Thank you! I didnt know you could do this. 

I haven ran the code and can get a good output but i'm missing the cpc_ceiling information. 

I've tried to look at the API documents but cant see a way to get this info. 

My portfolio (accessible) bid strategy is target_cpa and it has a tCPA set but also a bid ceiling (max CPC) and i'm trying to get the max cpc too, is there any way to do this too ? 

Thanks 

Google Ads Scripts Forum Advisor

unread,
Oct 13, 2022, 11:34:15 PM10/13/22
to adwords...@googlegroups.com

Hello Everyone,

This is Maia from the Google Ads Scripts Team.

@Nils - Thank you Nils for the inputs. Our team greatly appreciates the support you provide in this community.

@Ben - You may check out this accessible_bidding_strategy documentation on the available resource fields. On the other hand, if it suits your use case, you may utilize bidding_strategy granting that the Bid Strategy owner is not a Manager account. As an example, I have referenced Nils' query, but instead used bidding_strategy:

var gaqlQuery = "SELECT bidding_strategy.id, bidding_strategy.name, bidding_strategy.target_cpa.target_cpa_micros, bidding_strategy.target_cpa.cpc_bid_ceiling_micros FROM bidding_strategy";

However, for us to accurately address your concern, kindly share with us your Google Ads CIDScript name, and (if possible) screenshots in the Google Ads UI of the field you are trying to retrieve privately. This is for us to have a clear understanding of the blockers that you are experiencing.

If the `Reply privately to author` option is not available on your end, you may send those through the email alias `googleadsscr...@google.com` instead.

Best Regards,

Google Logo
Angel Maia
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2f63oT:ref

Ben Phelan

unread,
Oct 14, 2022, 10:36:59 AM10/14/22
to Google Ads Scripts Forum on behalf of adsscripts
Thanks everyone, this is really helpful! I got the data back I needed using the bidding_strategy method. 

Please note, I originally asked for the type=target_cpa. I also have campaigns with bidding strategies where the type is : maximize_conversions - the documentation says the field to use is bidding_strategy.maximise_conversions.target_cpa 

Using this field, i get an error, field not recognized. 

If I use, bidding_strategy.maximize_conversions.target_cpa_micros (which is not in the documentation) it works. 

E.g.
Bad
//var gaqlQuery =  "SELECT bidding_strategy.id, bidding_strategy.name, bidding_strategy.maximize_conversions.target_cpa, bidding_strategy.maximize_conversions.cpc_bid_ceiling_micros FROM bidding_strategy WHERE bidding_strategy.id ="+resourceId+"";

Good
   var gaqlQuery = "SELECT bidding_strategy.id, bidding_strategy.name, bidding_strategy.maximize_conversions.target_cpa_micros, bidding_strategy.maximize_conversions.cpc_bid_ceiling_micros FROM bidding_strategy WHERE bidding_strategy.id ="+resourceId+"";

Document and interactive query building is indicating to use the wrong field (unless i'm missing something) : https://developers.google.com/google-ads/api/fields/v10/bidding_strategy#bidding_strategy.maximize_conversions.target_cpa 

Thanks 





--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to a topic in the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-scripts/1N95e-jVFJ4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/Lbes_000000000000000000000000000000000000000000000RJQ4KQ00L_entalDTluRQnOJgOLupA%40sfdc.net.
Reply all
Reply to author
Forward
0 new messages