Set Daily Budgets with Google sheet

32 views
Skip to first unread message

Flags Importer

unread,
Dec 5, 2018, 4:01:56 PM12/5/18
to Google Ads Scripts Forum
I've been searching for something like this but can't find a similar discussion/question.

Currently I use automated rules to change budgets in a single account for the weekend and rules to change them back for the week days, but with a large number of campaigns this can get hard to fine tune.

Is there a script where I can use a google sheet to set budgets for each campaign each day of the week?

Vincent Racaza (AdWords Scripts Team)

unread,
Dec 5, 2018, 6:07:17 PM12/5/18
to Google Ads Scripts Forum
Hi,

I'm afraid that there is no readily available script that can set budgets for each campaign where the budget amount will be fetched from the Google spreadsheet. However, you may follow the instructions below to get you started on creating this script.

1.) First, you have to implement the SpreadsheetApp to retrieve data from the spreadsheet. You may refer to this link for your guide.
2.) Implement the campaign iterator to retrieve all the campaigns.
3.) Use the setAmount method to set the budget of the campaign.

You may refer to the sample script below as reference.

function main(){
 
var ss = SpreadsheetApp.openByUrl("INSERT_SPREADSHEET_URL_HERE");
 
var sheet = ss.getSheetByName("INSERT_SHEET_NAME_HERE");
 
var range = sheet.getRange("INSERT_CELL_RANGE_HERE");
 
var cellValues = range.getValues();
 
 
for (var i = 0; i < cellValues.length; i++) {    
   
var campaignIterator = AdsApp.campaigns()
       
.withCondition("Name = " + JSON.stringify(cellValues[i][0])); //The cellvalues[i][0] corresponds to the campaign names listed in the spreadsheet
       
.get();

   
while (campaignIterator.hasNext()) {
     
var campaign = campaignIterator.next();
     campaign
.getBudget().setAmount(cellValues[i][1]); //The cellvalues[i][1] is the corresponding amount budget of specific campaigns
     
Logger.log('Campaign with name = ' + campaign.getName() +
 
' has budget = ' + campaign.getBudget().getAmount());
   
}
 
}
}

You may test the provided sample script by clicking the PREVIEW button. After you confirmed that the script is working after previewing, you may schedule the script daily to update the budget amount daily. Also, you may update the script based on your preferences.

Please let me know if you have further questions/clarifications.

Regards,
Vincent
Google Ads Scripts Team

Response Links

Reply all
Reply to author
Forward
0 new messages