AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Ads
5.4K members online now
5.4K members online now
Dive into advanced features like Remarketing, Flexible Bid Strategies, AdWords Editor, and AdWords Scripts
Guide Me
star_border
Reply

Shared Budget Automation

Explorer ✭ ✭ ☆
# 1
Explorer ✭ ✭ ☆

Hi Community,

 

Just wondering if anyone knows of a script that will automatically change a Shared Budget on a specific date, say if a client wanted to raise their budget on a weekend and decrease it again when Monday rolls around.

 

Any help would be appreciated.

 

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Matthew L
November 2016

Re: Shared Budget Automation

Top Contributor
# 2
Top Contributor

Hi @Matthew L getting and setting Shared Budget amounts is relatively easy; ironically, it's more difficult to determine the day of the week!  Something like this should work, sorry I can test it fully as I don't have any clients using shared budgets.

 

// script to change budget by day of week
// Jon Gritton 2016

// user vars
var BUDG_NAME = "the budget name";
var B_MON = 10;
var B_TUE = 15;
var B_WED = 20;
var B_THU = 30;
var B_FRI = 40;
var B_SAT = 50;
var B_SUN = 55;

function main() {
  setBudget(getBudgetToday());
}

function getBudgetToday() {
  var budgArray = [B_SUN,B_MON,B_TUE,B_WED,B_THU,B_FRI,B_SAT];
  var d = new Date(Utilities.formatDate(new Date(), AdWordsApp.currentAccount().getTimeZone(), "MMM dd,yyyy HH:mm:ss"));
  var today = d.getDay();
  return budgArray[today];
}

function setBudget(budgetToday) {
  Logger.log("Budget for today is: " + budgetToday);
  var budgetIter = AdWordsApp.budgets()
    .withCondition("BudgetName = '" + BUDG_NAME + "'")
    .get()
  while (budgetIter.hasNext()) {
    var thisBudget = budgetIterator.next();
    thisBudget.setAmount(budgetToday);
  }
}

Edit it to enter your own budget name and to change the daily budget figures for each day of the week then PREVIEW it and check the result is as expected before setting it to run on a schedule.  I'd recommend running daily at midnight.

 

Jon

AdWords Top Contributor Google+ Profile | Partner Profile | AdWords Audits

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author Matthew L
November 2016

Re: Shared Budget Automation

Top Contributor
# 2
Top Contributor

Hi @Matthew L getting and setting Shared Budget amounts is relatively easy; ironically, it's more difficult to determine the day of the week!  Something like this should work, sorry I can test it fully as I don't have any clients using shared budgets.

 

// script to change budget by day of week
// Jon Gritton 2016

// user vars
var BUDG_NAME = "the budget name";
var B_MON = 10;
var B_TUE = 15;
var B_WED = 20;
var B_THU = 30;
var B_FRI = 40;
var B_SAT = 50;
var B_SUN = 55;

function main() {
  setBudget(getBudgetToday());
}

function getBudgetToday() {
  var budgArray = [B_SUN,B_MON,B_TUE,B_WED,B_THU,B_FRI,B_SAT];
  var d = new Date(Utilities.formatDate(new Date(), AdWordsApp.currentAccount().getTimeZone(), "MMM dd,yyyy HH:mm:ss"));
  var today = d.getDay();
  return budgArray[today];
}

function setBudget(budgetToday) {
  Logger.log("Budget for today is: " + budgetToday);
  var budgetIter = AdWordsApp.budgets()
    .withCondition("BudgetName = '" + BUDG_NAME + "'")
    .get()
  while (budgetIter.hasNext()) {
    var thisBudget = budgetIterator.next();
    thisBudget.setAmount(budgetToday);
  }
}

Edit it to enter your own budget name and to change the daily budget figures for each day of the week then PREVIEW it and check the result is as expected before setting it to run on a schedule.  I'd recommend running daily at midnight.

 

Jon

AdWords Top Contributor Google+ Profile | Partner Profile | AdWords Audits

Shared Budget Automation

Explorer ✭ ✭ ☆
# 3
Explorer ✭ ✭ ☆

Worked perfectly, thanks Jon!

Shared Budget Automation

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

Hey Jon,

 

Is there a script that could increase budgets by 25% on a Monday and then reduce them on a Tuesday? 

It would need to be capable to do so for campaigns using shared budgets.

 

Cheers,

AD