Hi,
We are working in an industry where we often get hit by disapproved and strongly restricted ads due to the nature of the products that we are selling (toys for adults).
I am trying to figure out if we can set up a script that sends an email each week with the count of disapproved ads, and strongly restricted ads in an account.
I've asked ChatGPT and Bard and get some suggestions to a script, but both models seem to use fields that are not available.
The error message I get is "
QueryError.UNRECOGNIZED_FIELD: Unrecognized fields in the query: 'approvalSummary.status', 'status'."
And the script I try to use is:
function main() {
var disapprovedAds = 0;
var emailBody = '';
// Get all ads in the account
var adIterator = AdsApp.ads()
.withCondition('approvalSummary.status = DISAPPROVED AND status = ENABLED')
.get();
// Count the number of disapproved ads
while (adIterator.hasNext()) {
disapprovedAds++;
}
// If there are disapproved ads, send an email
if (disapprovedAds > 0) {
emailBody = 'There are ' + disapprovedAds + ' disapproved ads in your account.';
var emailTo = '
yo...@email.com';
var emailSubject = 'Disapproved Ads Alert';
var emailContent = {
from: 'Google Ads Notification',
to: emailTo,
subject: emailSubject,
body: emailBody
};
MailApp.sendEmail(emailContent);
}
}
Would be great if anyone had suggestions to how to get this script up and running, since it would save us considerable time, checking each account we have.
With best regards