best practice setting keyword bids

37 views
Skip to first unread message

Matthias Baader

unread,
Aug 26, 2017, 2:53:28 AM8/26/17
to AdWords Scripts Forum
Hi,

as a result of some calculation in my script, I end up with an object like this, containing all individual bids, I want to set for each keyword in all the adGroups of a campaign:

map[campaignId][adGroupId][id]["bid"]=0.5

Now: what is considered as best practice to set the individual keyword bids (with regard to speed), if we talk about thousands of keywords, each with an individual bid? 

Best regards
Matthias

Tyler Sidell (AdWords Scripts Team)

unread,
Aug 28, 2017, 10:59:21 AM8/28/17
to AdWords Scripts Forum
Hi Matthias,

Thanks for reaching out with your inquiry about speed and best practices.  We do have a Best Practices page that discusses topics such as speed.  if you are looking for best practices for setting keyword bids in bulk, you may want to take a look at the example we provide under the batch changes section.

Let us know if you have any questions.

Thanks,
Tyler Sidell
AdWords Scripts Team

Matthias Baader

unread,
Aug 29, 2017, 1:30:02 AM8/29/17
to AdWords Scripts Forum
Thank you Tyler for providing that solution.

The point is, not to set a common CPC for all keywords, like in that batch change solution, but an individual one for each. Currently, my script is looping through the above mentioned object like

for (var campaignId in map){
for (var adGroupId in map[campaignId]){
for (var id in map[campaignId][adGroupId]){
var bid = map[campaignId][adGroupId][id]["bid"];
var keywordId = [[adGroupId, id]];
var keyword = AdWordsApp.keywords()
.withIds(keywordId)
.get()
.next();
keyword.bidding().setCpc(bid);
}
}
}


...and this gives me a pretty good performance. But I was wondering, if there is a better way.

Best regards
Matthias

Joyce Lava (AdWords Scripts Team)

unread,
Aug 29, 2017, 6:05:52 AM8/29/17
to AdWords Scripts Forum
Hi Matthias,

Since the value of each bid comes from an array mapping with different values, your current code is the only way to achieve your use-case.

Thanks,
Joyce Lava
AdWords Scripts Team

Matthias Baader

unread,
Aug 29, 2017, 11:46:04 AM8/29/17
to AdWords Scripts Forum
Hi Joyce,

thank you very much for the clarification!

Best regards
Matthias

Trevor

unread,
Aug 29, 2017, 1:06:21 PM8/29/17
to AdWords Scripts Forum
Alternatively however, you could create a bulk upload, pull a report of every keyword in the account (with campaign ID, ad group ID, and keyword ID as columns), iterate through each row, and one by one use the ids to look up the bid in your map and replace the bid in the row, pushing each into the bulk upload. At the end the script would push the bulk upload all at once.

In more detail, you'd create the upload with newCsvUpload() (setting the column headers as appropriate), then set up a row iterator for the keyword report, and for each row:

var upload = AdWordsApp.bulkUploads().newCsvUpload(---column headers set up here---)
var report = AdWordsApp.report("SELECT CampaignId, AdGroupId, Id, CpcBid FROM KEYWORD_PERFORMANCE_REPORT"); // Something like this, I haven't tested this query

var reportIterator = report.rows();

while (reportIterator.hasNext()) {
  row
= rows.next();
  row
['CpcBid'] = map[row['CampaignId']][row['AdGroupId'][row['Id']["bid"];
  upload
.append(row.formatForUpload());
}

upload
.apply;  // or preview


The above code is psuedo-esque code (untested) but hopefully the concept makes sense.

Trevor

unread,
Aug 29, 2017, 1:07:48 PM8/29/17
to AdWords Scripts Forum
Forgot a bracket in this line:

row['CpcBid'] = map[row['CampaignId']][row['AdGroupId'][row['Id']]["bid"];


Matthias Baader

unread,
Aug 31, 2017, 1:57:08 AM8/31/17
to AdWords Scripts Forum
Thank you Trevor for providing this solution. I will give it a try.

Best regards
Matthias
Reply all
Reply to author
Forward
0 new messages