Reports

Create a text report

function runReport() {
  // Google Ads reports return data faster than campaign management methods
  //   and can be used to retrieve basic structural information on
  //   your Account, Campaigns, AdGroups, Ads, Keywords, etc. You can refer to
  //   https://developers.google.com/google-ads/api/docs/reporting/overview
  //   for more details.

  // See https://developers.google.com/google-ads/api/fields/latest/overview#list-of-all-resources
  //   for all the supported report types.
  // See https://developers.google.com/google-ads/api/docs/query/overview for
  //   details on how to use GAQL, the query language for reports.
  // See https://developers.google.com/google-ads/api/docs/reporting/uireports
  //   for details on how to map an Google Ads UI feature to the corresponding
  //   reporting API feature.
  const searchResults = AdsApp.search(
      'SELECT campaign.name, metrics.clicks, metrics.impression, metrics.cost ' +
      'FROM   campaign ' +
      'WHERE  metrics.impressions < 10 ' +
      ' AND   segments.date DURING LAST_30_DAYS');

  for (const row of searchResults) {
    const campaignName = row.campaign.name;
    const clicks = row.metrics.clicks;
    const impressions = row.metrics.impressions;
    const cost = row.metrics.cost;
    console.log(`${campaignName}, ${clicks}, ${impressions}, ${cost}`);
  }
}

Create a spreadsheet report

function exportReportToSpreadsheet() {
  const spreadsheet = SpreadsheetApp.create('INSERT_REPORT_NAME_HERE');
  const report = AdsApp.report(
      'SELECT campaign.name, metrics.clicks, metrics.impression, metrics.cost ' +
      'FROM   campaign ' +
      'WHERE  metrics.impressions < 10 ' +
      ' AND   segments.date DURING LAST_30_DAYS');
  report.exportToSheet(spreadsheet.getActiveSheet());
}

Filter entities by label

function filterReportByLabelIds() {
  const label = AdsApp.labels().withCondition(
      "label.name = 'High performance campaigns'").get().next();
  const query = `SELECT campaign.name, metrics.clicks, metrics.impressions, metrics.cost from ` +
      `campaign WHERE campaign.labels CONTAINS ANY ` +
      `[${label.getResourceName()}] AND segments.date DURING THIS_MONTH';

  const report = AdsApp.report(query);

  for (const row of report.rows()) {
    const campaignName = row['campaign.name'];
    const clicks = row['metrics.clicks'];
    const impressions = row['metrics.impressions'];
    const cost = row['metrics.cost'];
    Logger.log(`${campaignName}, ${clicks}, ${impressions}, ${cost}`);
  }
}