How do I create a script that check call extensions are disapproved or not

130 views
Skip to first unread message

Tirth Luhar

unread,
Aug 3, 2021, 4:58:19 AM8/3/21
to Google Ads Scripts Forum
Hello Google Team,

I want to create a script which check call extensions and other extensions are approved or not

Google Ads Scripts Forum Advisor

unread,
Aug 4, 2021, 3:24:38 AM8/4/21
to adwords...@googlegroups.com
Hi Tirth,

You may utilize the Placeholder Feed Item Report, then use the DisapprovalShortNames which returns a list of reasons why the FeedItem is not approved and also the ValidationDetails attribute which will return details about the validation state or simply the approval status.

Regards,
Google Logo
Teejay Wennie Pimentel
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2HLJto:ref

Nils Rooijmans

unread,
Aug 4, 2021, 3:31:01 AM8/4/21
to Google Ads Scripts Forum
Here's a complete example of a script you can use:

Hope this helps, 

Nils Rooijmans 
See my Google Ads Scripts FAQ to avoid the same mistakes I made: https://nilsrooijmans.com/google-ads-scripts-faq/


Axenia Samocrainai

unread,
Sep 20, 2023, 10:19:26 PM9/20/23
to Google Ads Scripts Forum
Hello, 
This script is no longer compatible with the new version of Google Ads API. Does anyone have an updated version of the feed?

Joe Davis

unread,
Oct 10, 2023, 11:25:14 AM10/10/23
to Google Ads Scripts Forum
var spreadSheetId = 'google sheet here';
var accounts;
var EMAIL =  'email here';

function main() {
  var accounts = AdsManagerApp.accounts()
    .withCondition('LabelNames CONTAINS "label name here"')
    .get();

  var data = [];

  while (accounts.hasNext()) {
    var account = accounts.next();
    AdsManagerApp.select(account);

    var query = "SELECT campaign.id, campaign_asset.status, campaign.status, campaign.experiment_type, campaign.name, asset.id, asset.type, asset.policy_summary.approval_status FROM campaign_asset WHERE asset.policy_summary.approval_status = 'DISAPPROVED' AND campaign.status = 'ENABLED' AND campaign.experiment_type = 'BASE' AND campaign_asset.status = 'ENABLED'";
    var accountReport = AdsApp.report(query);

    var accountRows = accountReport.rows();
    while (accountRows.hasNext()) {
      var row = accountRows.next();
     
      data.push([
        account.getName(),
        row['campaign.name'],
        row['asset.id'],
        row['asset.type'],
        row['asset.policy_summary.approval_status']
      ]);
    }
  }

  var sheetName = Utilities.formatDate(new Date(), "GMT", "dd/MM/yy");
  writeToSheet(spreadSheetId, sheetName, data);

  // Send email if there is data
  if (data.length > 0) {
    sendEmail(spreadSheetId, data);
  }
}

function writeToSheet(spreadsheetId, sheetName, data) {
  var spreadsheet = SpreadsheetApp.openById(spreadsheetId);
  var sheet = spreadsheet.getSheetByName(sheetName);
 
  if (!sheet) {
    sheet = spreadsheet.insertSheet(sheetName);
    Logger.log("Sheet '" + sheetName + "' created in the specified Google Sheet.");
  }

  sheet.clearContents();
  if (data.length > 0) {
    sheet.getRange(1, 1, 1, 5).setValues([['Account Name', 'Campaign Name', 'Asset ID', 'Asset Type', 'Approval Status']]);
    sheet.getRange(2, 1, data.length, data[0].length).setValues(data);
    Logger.log("Data written to the sheet '" + sheetName + "'.");
  } else {
    Logger.log("No data to write to the sheet.");
  }
}

function sendEmail(id, data) {
  const sheetUrl = SpreadsheetApp.openById(id).getUrl();
  var emailBody = 'ALERT - Disapproved Asset Detected\n\n';

  for (var i = 0; i < data.length; i++) {
    emailBody += 'Account Name: ' + data[i][0] + '\n';
    emailBody += 'Campaign Name: ' + data[i][1] + '\n';
    emailBody += 'Item ID: ' + data[i][2] + '\n';
    emailBody += 'Asset Type: ' + data[i][3] + '\n';
    emailBody += 'Approval Status: ' + data[i][4] + '\n\n';
  }
 
  MailApp.sendEmail({
    to: EMAIL,
    subject: 'ALERT - Disapproved Asset Detected',
    body: emailBody + 'Spreadsheet URL: ' + sheetUrl
  });
Reply all
Reply to author
Forward
0 new messages