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

MCC Script: Bulk Pause all campaigns within accounts with LABEL X

J M
Follower ✭ ☆ ☆
# 1
J M
Follower ✭ ☆ ☆

We have hundreds of accounts currently running that need to turn off tomorrow. I'd like to setup an automation to pause all campaigns within any account that is labeled with "X." Unfortunately, filtering by label and selecting all the accounts myself is not a solution as creating an automation rule forces you to then select accounts by name and doesn't take into account what you have checked/selected prior.

 

Would someone be able to create a MCC script that would achieve what I'm looking for?

 

 

1 Expert replyverified_user

Re: MCC Script: Bulk Pause all campaigns within accounts with LABEL X

Top Contributor
# 2
Top Contributor

Hi @J M here's how to iterate through Accounts at the MCC level:

 

function main() {
iterateAcc();
}

function iterateAcc() {
//step through the Accounts, only one right now, but we can add others if needed.
//when we do, we can use parallel processing to ensure they run in time.
var accIter = MccApp.accounts()
.get();

while(accIter.hasNext()) {
var theAccount = accIter.next();
MccApp.select(theAccount);
processAccount(theAccount.getName());
}
}

 

//now the code to process the Account

 

function processAccount(accName) {

var theCamps = AdWordsApp.campaigns()

  .withCondition("Status = ENABLED")
.withCondition("LabelNames CONTAINS_ALL ['X']")
.get();

 

while(theCamps.hasNext()) {

var thisCamp = theCamps.next();

thisCamp.pause();

}

}

 

that should get you close.  Preview it to check it works, then set it to run close to midnight...

 

Jon

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

Re: MCC Script: Bulk Pause all campaigns within accounts with LABEL X

Follower ✭ ✭ ✭
# 3
Follower ✭ ✭ ✭
Hi Jon_Gritton,

I need a script for my MCC that could create a label to all my enabled campaigns for all the accounts linked with my MCC. Kindly help me about it.