Adwords bids

75 views
Skip to first unread message

Del Stone

unread,
Jun 1, 2018, 12:02:33 PM6/1/18
to AdWords Scripts Forum
Hi

I need to put a script together so I can set bids for keywords based on call durations.

The steps are as follows:
- Set up 3 arrays for keywords, adgroups, campaigns containing the total number of calls, total duration and average call durations since the start of the account
- Loop through all keywords in all campaigns with 1 or more clicks
- if it has more than 10 calls, set cpa = kw average ;
      if not, if adgroup has 10 or more calls set cpa = that average;
      otherwise set cpa = campaign average;
- calculate max cpa bid as cpa * click conversion rate
- if max cpa bid > first position bid then
     if max cpc bid >= max cpa and lost search impression > 20% then set max cpa = max cpc bid * 1.20
     otherwise set max cpa = top of page bid
otherwise if max cpa < first page bid
    if max cpa is below first page bid by 20% and quality score > 6 set it max cpa = first page bid
otherwise (it is in between)
   if kw qs > 7 and lost share impression > 20% and simulated bid cost per keyword < max cpa set max cpa = the highest profitable level
- set max cpc = max cpa

Could you help out with a skeletal script that does the above please? I can then add the further details I need to fill it out.

Thanks in advance.

Anthony Madrigal

unread,
Jun 1, 2018, 4:14:05 PM6/1/18
to AdWords Scripts Forum
Hello,

Can you please elaborate/clarify on some on these points:
  • From the Keyword level, there is no function to set CPA, only CPC and CPM
  • What level are you interested in the calls for? They are currently only available at the campaign and ad group level, not the keyword level
You can use a KeywordSelector to get all your keywords using withConditions that you specify. Once you have them, you can use the functions setCpc and setCpm to modify your keyword bids.

Regards,
AdWords Scripts Team

delstoneservices

unread,
Jun 1, 2018, 10:59:27 PM6/1/18
to AdWords Scripts Forum on behalf of Anthony Madrigal
Hi Anthony 

The cpa  would be an intermediate working variable. It would be max cpc we are ultimately setting.
Calls on the calls details report in dimensions on new beta interface for instance are logged at campaign, ad group and kw level. I am not sure how to pull in everything needed from there.

Could you help with some skeletal script which I can then build upon with other requirements I have not listed...
--
-- 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 the Google Groups "AdWords Scripts Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/fea7c90b-46ca-40ce-8d75-24a7eda7e836%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anthony Madrigal

unread,
Jun 4, 2018, 2:56:39 PM6/4/18
to AdWords Scripts Forum
Hi,

It does not seem currently possible to get the call details from the keyword level via AdWords Scripts.

Here is some code to help you get started to do some of the scenarios you are using:
function main(){
 
//Loop through all keywords in all campaigns with 1 or more clicks
 
var report = AdWordsApp.report(
   
'SELECT AdGroupId,Id,Criteria,ConversionRate,CpcBid,FirstPageCpc,TopOfPageCpc,QualityScore,SearchRankLostImpressionShare ' +
   
'FROM   KEYWORDS_PERFORMANCE_REPORT ' +
   
'WHERE  Clicks > 0 ' +
   
'DURING LAST_30_DAYS');
 
 
var rows = report.rows();
 
while (rows.hasNext()) {
   
var row = rows.next();
   
var adGroup = row['AdGroupId'];
   
var id = row['Id'];
   
var criteria = row['Criteria'];
   
var cr = row['ConversionRate'];
   
var cpc = row['CpcBid'];
   
var fpcpc = row['FirstPageCpc'];
   
var topcpc = row['TopOfPageCpc'];
   
var qs = row['QualityScore'];
   
var lis = row['SearchRankLostImpressionShare'];
   
//calculate max cpa bid as cpa * click conversion rate
   
var maxcpa = parseFloat(cpc) * parseFloat(cr);
   
   
//if max cpa bid > first position bid then
   
if(maxcpa > parseFloat(fpcpc)){
     
var kw = AdWordsApp.keywords().withIds([[adGroup,id]]).get().next();
     
//if max cpc bid >= max cpa and lost search impression > 20% then set max cpa = max cpc bid * 1.20
     
if(parseFloat(cpc) >= maxcpa && parseFloat(lis) > 20){
        kw
.bidding().setCpc(cpc*1.2);
     
}//otherwise set max cpa = top of page bid
     
else{
        kw
.bidding().setCpc(parseFloat(topcpc));
     
}
   
}
   
//otherwise if max cpa < first page bid
   
else {
     
var kw = AdWordsApp.keywords().withIds([[adGroup,id]]).get().next();
     
//if max cpa is below first page bid by 20% and quality score > 6 set it max cpa = first page bid
     
if(maxcpa < parseFloat(fpcpc)*.8 && parseInt(qs) > 6){
        kw
.bidding().setCpc(parseFloat(fpcpc));          
     
}        
   
}
 
}
}

Regards,
Anthony
AdWords Scripts Team

delstone

unread,
Jun 4, 2018, 6:26:08 PM6/4/18
to AdWords Scripts Forum on behalf of Anthony Madrigal

Thanks for that Anthony. That’s really helpful.

 

Just one more qu, if call duration isn’t available for kw, how would I populate an array for each kw for average call duration for each campaign and each adgroup?

 

From: Anthony Madrigal via AdWords Scripts Forum <adwords-scripts+APn2wQdtTxVvWMRs...@googlegroups.com>
Sent: 04 June 2018 19:57
To: AdWords Scripts Forum <adwords...@googlegroups.com>
Subject: Re: Adwords bids

 

Hi,

-------- Original message --------

Anthony Madrigal

unread,
Jun 5, 2018, 3:27:04 PM6/5/18
to AdWords Scripts Forum
Hi,

You will need to run a Call Metrics Call Details Report to get call details including its campaign and ad groups.

Regards,
Anthony
AdWords Scripts Team

-------- Original message --------

delstone

unread,
Jun 5, 2018, 3:48:56 PM6/5/18
to AdWords Scripts Forum on behalf of Anthony Madrigal

Could you help with some code please?

 

From: Anthony Madrigal via AdWords Scripts Forum <adwords-scripts+APn2wQdtTxVvWMRs...@googlegroups.com>
Sent: 05 June 2018 20:27
To: AdWords Scripts Forum <adwords...@googlegroups.com>
Subject: Re: Adwords bids

 

Hi,

 

You will need to run a Call Metrics Call Details Report to get call details including its campaign and ad groups.

-------- Original message --------

Anthony Madrigal

unread,
Jun 6, 2018, 3:23:14 PM6/6/18
to AdWords Scripts Forum
Hello,

You could add this to the snippet I provided:
function main(){
 
//Loop through all keywords in all campaigns with 1 or more clicks
 
var report = AdWordsApp.report(

   
'SELECT CampaignId,AdGroupId,Id,Criteria,ConversionRate,CpcBid,FirstPageCpc,TopOfPageCpc,QualityScore,SearchRankLostImpressionShare ' +

   
'FROM   KEYWORDS_PERFORMANCE_REPORT ' +
   
'WHERE  Clicks > 0 ' +
   
'DURING LAST_30_DAYS');
 
 
var rows = report.rows();
 
while (rows.hasNext()) {
   
var row = rows.next();

   
var campaign = row['CampaignId'];

   
var adGroup = row['AdGroupId'];
   
var id = row['Id'];
   
var criteria = row['Criteria'];
   
var cr = row['ConversionRate'];
   
var cpc = row['CpcBid'];
   
var fpcpc = row['FirstPageCpc'];
   
var topcpc = row['TopOfPageCpc'];
   
var qs = row['QualityScore'];
   
var lis = row['SearchRankLostImpressionShare'];
   
//calculate max cpa bid as cpa * click conversion rate
   
var maxcpa = parseFloat(cpc) * parseFloat(cr);

   
   
//Get call details of campaign and ad groups
   
var report2 = AdWordsApp.report(
   
'SELECT CampaignId,AdGroupId,CallDuration ' +
   
'FROM   CALL_METRICS_CALL_DETAILS_REPORT ' +
   
'DURING LAST_30_DAYS');
   
   
var rows2 = report2.rows();
   
var calls = 0;
   
var i = 0;
   
while(rows2.hasNext()){
     
var row2 = rows2.next();
     
var call = row2['CallDuration'];
      calls
+= parseFloat(call);
      i
++;
   
}
   
//get average call duration
    calls
= calls/i;

   
   
//rest of code
   
......
 
}
}

Regards,
Anthony
AdWords Scripts Team

-------- Original message --------

Reply all
Reply to author
Forward
0 new messages