MCC Script: Automatically Increase Campaign Budgets and Email Changes

Reading Time: 3 minutes

This script

  • checks hourly the spent of campaign for today
  • and if it’s higher than a set threshold % from its budget
  • it will increase the budget by the percentage you set
  • and email you changes – 1 email per 1 account processed
  • avoiding the campaigns you marked not to touch.
MCC Script: Automatically Increase Campaign Budgets and Email Changes
MCC Script: Automatically Increase Campaign Budgets and Email Changes

Shortcuts:

> when you might need it <

> how to set it up <

> script code <


When this is useful?

Primarily the point of this script is not to miss out on seasonal traffic RIGHT AWAY when people go crazy (and desperate) searching for gifts and quadruple your website clicks.

The latest update from Google Ads is that your budget can always be doubled by the system, but will remain within “your budget * 30.5” for the whole month. Cool feature (and a headache for some advertisers)! However Black Friday and Christmas are very much two hu-u-u-uge anomalies.

Of course you can just increase your budget x5-20 times for THE season and leave it be, but (since we established i’m a paranoid person in a previous script article) I prefer not to leave my budget to chance and human-error even if it’s mine, and would like to get notified when my previous budget is not enough anymore.


How to set up the script?

1. Go to the MCC level.

2. Click Tools > Scripts, click to add new script.

3.  Paste the code below, update the *settings* part so that it makes sense for you.

4. Save the script and schedule it to run hourly.


Script code

/********** settings ***********/

var email = "[email protected]"; 
var account_label = "ADD HERE YOUR ACCOUNTS LABEL";
var accounts = ["SAMPLE ACCOUNT 1", "SAMPLE ACCOUNT 2", "SAMPLE ACCOUNT 3"];
var campaign_label = "ADD HERE LABEL YOU USED ON CAMPAIGNS TO SKIP";  // i use "ignore budget" :)
var percentage = 0.8; // change budget when cost today is already >80% of the campaign budget (0.9 means >90% etc.)
var new_budget_percentage = 1.5; // increase campaign budget by 50% (2 for 200% etc.)

/*********** magic *************/

function main() {
for (var i=0; i<accounts.length; i++) {
var accountIterator = MccApp.accounts().withCondition('LabelNames CONTAINS ' + account_label).withCondition("Name CONTAINS '" + accounts[i] + "'").get();
while (accountIterator.hasNext()) {
var account = accountIterator.next();
var account_name = account.getName();
MccApp.select(account)


var campaigns = AdWordsApp.campaigns().withCondition('Status = ENABLED').withCondition("LabelNames != '" + campaign_label + "'").get();
var campList = "";
while(campaigns.hasNext()) {
var campaign = campaigns.next();
var stats = campaign.getStatsFor("TODAY");
var budget = campaign.getBudget();
var spend = stats.getCost();
var spend_rounded = Math.round(spend);
var campaign_name = campaign.getName();

if(spend > (budget * percentage)) {
Logger.log("Campaign: " + campaign_name + " Budget: " + budget + " Spend: " + spend_rounded);
var new_budget = budget * new_budget_percentage;
var new_budget_rounded = Math.round(new_budget);
budget.setAmount(new_budget_rounded);
Logger.log("Campaign: " + campaign_name + " >>>>>> new Budget is " + new_budget_rounded + "\n");
campList += "Campaign: " + campaign_name + " --- Cost today: " + spend_rounded + " --- Budget: " + budget + " >>> " + new_budget_rounded + "\n";
}
}
}

if(campList.length !=0) { 
sendEmail(email,campList,account_name);
}
}

function sendEmail(email, body, account_name) {
var subject = "Account '" + account_name + "' - Campaign budgets were increased";
Logger.log("Sending email, subject: " + subject);
MailApp.sendEmail(email,subject, body);
}
}

If filtering by account label is enough for you and you don’t need to also limit it to specific accounts then do this:

delete line
var accounts = ["SAMPLE ACCOUNT 1", "SAMPLE ACCOUNT 2", "SAMPLE ACCOUNT 3"];

remove the "for i" loop
for (var i=0; i<accounts.length; i++) {
} 
(you can find the second bracket by putting cursor to the first one 
and they both will light up with green color in google ads interface)

remove from accountIterator this part
.withCondition("Name CONTAINS '" + accounts[i] + "'")
1 reply on “ MCC Script: Automatically Increase Campaign Budgets and Email Changes ”
Leave a Reply

Your email address will not be published. Required fields are marked *