function main() {
var accounts = [];
var MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
var now = new Date();
var yesterday = new Date(now.getTime() - MILLIS_PER_DAY);
var accountIterator = MccApp.accounts().withLimit(50).get();
var mccAccount = AdWordsApp.currentAccount();
while (accountIterator.hasNext()) {
var account = accountIterator.next();
// Switch to the account you want to process.
MccApp.select(account);
var impressions = account.getStatsFor('YESTERDAY').getImpressions();
if(impressions == 0){
accounts.push(account.getCustomerId());
}
}
if(accounts.length > 0)
MailApp.sendEmail('YOUR EMAIL', 'Accounts with no impressions on ' + yesterday, accounts);
}
function main() {
var accounts = [];
var MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
var now = new Date();
var yesterday = new Date(now.getTime() - MILLIS_PER_DAY);
var accountIterator = MccApp.accounts().withLimit(50).get();
var mccAccount = AdWordsApp.currentAccount();
while (accountIterator.hasNext()) {
var account = accountIterator.next();
// Switch to the account you want to process.
MccApp.select(account);
var impressions = account.getStatsFor('YESTERDAY').getImpressions();
if(impressions == 0){
accounts.push(account.getCustomerId()+"\n"); // \n adds a new line
}
} var acts = accounts.join(''); //joins the array and removes the comma (,) delimiter
if(accounts.length > 0)
MailApp.sendEmail('YOUR EMAIL', 'Accounts with no impressions on ' + yesterday, acts);
} if(impressions == 0){
accounts.push(account.getCustomerId()+" "+ "-" + " ")
accounts.push(account.getName()+"\n"); // \n adds a new linefunction main() {
var ctr= 0; //counter for accounts
var accounts = [];
var MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
var now = new Date();
var yesterday = new Date(now.getTime() - MILLIS_PER_DAY);
var accountIterator = MccApp.accounts().withLimit(50).get();
var mccAccount = AdWordsApp.currentAccount();
while (accountIterator.hasNext()) {
var account = accountIterator.next();
// Switch to the account you want to process.
MccApp.select(account);
var impressions = account.getStatsFor('YESTERDAY').getImpressions();
if(impressions == 0){
ctr++;
accounts.push(ctr+" "+account.getCustomerId()+" "+ "-" + " ")
accounts.push(account.getName()+"\n"); // \n adds a new line
}
}
var acts = accounts.join(''); //joins the array and removes the comma (,) delimiter
if(accounts.length > 0)
MailApp.sendEmail('YOUR EMAIL', 'Accounts with no impressions on ' + yesterday, acts);
}- For MCC scripts, 50 accounts can be processed. Each account that is handled by an MCC script do have different limits per iterator, selector, and script. Do read this for further information.
- Below is the updated version of your script. Do take note the emphasized parts of your current script as these are the changes made.
function main() {
var ctr= 0; //counter for accounts
var accounts = [];
var MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
var now = new Date();
var yesterday = new Date(now.getTime() - MILLIS_PER_DAY);
var accountIterator = MccApp.accounts().withLimit(50).get();
var mccAccount = AdWordsApp.currentAccount();
while (accountIterator.hasNext()) {
var account = accountIterator.next();
// Switch to the account you want to process.
MccApp.select(account);
var campaignSelector = AdWordsApp
.campaigns().withCondition("Status=ENABLED");
var campaignIterator = campaignSelector.get();
// checks the number of enabled campaigns. If none, the next account will be processed.
if (campaignIterator.totalNumEntities()!=0){
var impressions = account.getStatsFor('YESTERDAY').getImpressions();
if(impressions == 0){
ctr++;
accounts.push(ctr+" "+account.getCustomerId()+" "+ "-" + " ")
accounts.push(account.getName()+"\n"); // \n adds a new line
}
}
}
var acts = accounts.join(''); //joins the array and removes the comma (,) delimiter
if(accounts.length > 0)
MailApp.sendEmail('YOUR EMAIL', 'Accounts with no impressions on ' + yesterday, acts);
}
- As what I answered above, an MCC script can process up to 50 accounts. If more than 50 accounts are iterated, either a warning will be logged, or the script will throw a runtime error. If you want more than 50 accounts to be processed, you could generate multiple versions of the script that each run a certain group of accounts at a time.
- As per what my teammate said on his previous replies, there is no way to get alerts based on payments via AdWords Scripts.
var accountIterator = MccApp.accounts().withLimit(50)
.withIds(['XXX-XXX-XXXX', 'XXX-XXX-XXXX', 'XXX-XXX-XXXX']) //insert 50 IDs here
.get();Hi,
Thanks for reaching out. The MCC Account Selector only lets you retrieve metrics on client accounts. Thus, implementing your idea to check impressions on multiple MCC accounts is not possible on the Google Ads Scripts. If you would like, you can run the same script on each MCC account to check and get alerts on accounts without impressions in which your script would look like the following code:
var accountSelector = AdsManagerApp
.accounts()
.withCondition("Impressions < 1")
.forDateRange("LAST_MONTH");
var accountIterator = accountSelector.get();
var emailBody = '';
while (accountIterator.hasNext()) {
var account = accountIterator.next();
emailBody += account.getName() + '\n';
}
if(emailBody) {
MailApp.sendEmail("reci...@example.com", "No Impressions on Accounts", emailBody);
}
Let me know if you have other questions.
Thanks,
|
||||||