Quick summary

  • The script fetches, cleans, and records data; the spreadsheet is for display and review.
  • Apps Script has a 6-minute execution limit, and the API allows 25,000 rows per request.
  • Calculate click-through rate as total clicks ÷ total impressions, not by averaging rates.
  • Send an alert when a run fails so an outdated dashboard does not appear current.

To automate a weekly Google Search Console report in Google Sheets without copying and pasting, use Google Apps Script, Google’s cloud-based JavaScript platform. Schedule it to fetch data and write it to separate sheets for raw data, comparisons, and opportunities. This guide is for SEO professionals and marketers: keep raw data and final metrics on separate sheets.

Start with the report question, not the code

A good report answers a specific question: Which pages have gained impressions without gaining clicks? Which queries are new this week? Has performance declined for a particular business category? Define the following before writing any code:

  • Property type: Domain property or URL-prefix property.
  • The period and comparison period (e.g. the last 28 days versus the previous 28 days).
  • Dimensions: page, query, device, country.
  • A minimum impression threshold to keep low-value rows out of the report.

What does the Search Analytics API return?

ItemValue in the documentationImpact on the report
Required fieldsstartDate and endDateInclude the time zone and period in the report header
Maximum rows25,000 rows per request + startRowPaginate requests for large sites
Data retention period16 monthsStore your own copy for longer year-over-year comparisons
Anonymous queriesHidden to protect privacyClicks summed across queries ≠ total clicks
Permissionwebmasters.readonlySufficient for read access and reduces risk

Practical example: fetch data and write it to the sheet

The following function requests data for the last 28 days by page and query, then writes it all at once to a sheet named current. Set up a weekly time-driven trigger for it from the Triggers menu in the script editor.

function fetchSearchConsole() {
  const site = 'sc-domain:example.com';
  const tz = Session.getScriptTimeZone();
  const day = 24 * 60 * 60 * 1000;
  const end = Utilities.formatDate(new Date(Date.now() - 3 * day), tz, 'yyyy-MM-dd');
  const start = Utilities.formatDate(new Date(Date.now() - 30 * day), tz, 'yyyy-MM-dd');
  const url = 'https://www.googleapis.com/webmasters/v3/sites/' +
    encodeURIComponent(site) + '/searchAnalytics/query';

  const res = UrlFetchApp.fetch(url, {
    method: 'post',
    contentType: 'application/json',
    headers: { Authorization: 'Bearer ' + ScriptApp.getOAuthToken() },
    payload: JSON.stringify({ startDate: start, endDate: end, dimensions: ['page', 'query'], rowLimit: 25000 }),
    muteHttpExceptions: true
  });
  if (res.getResponseCode() !== 200) throw new Error(res.getContentText());

  const rows = (JSON.parse(res.getContentText()).rows || [])
    .map(r => [...r.keys, r.clicks, r.impressions, r.ctr, r.position]);
  const sheet = SpreadsheetApp.getActive().getSheetByName('current');
  sheet.getRange(2, 1, Math.max(sheet.getLastRow() - 1, 1), 6).clearContent();
  if (rows.length) sheet.getRange(2, 1, rows.length, 6).setValues(rows);
}

The project needs these permissions in appsscript.json, and the account running it must have access to the Search Console property:

"oauthScopes": [
  "https://www.googleapis.com/auth/webmasters.readonly",
  "https://www.googleapis.com/auth/script.external_request",
  "https://www.googleapis.com/auth/spreadsheets.currentonly"
]

Why end the reporting period 3 days early?

Search Console data arrives roughly two to three days late, so the most recent days are incomplete. Ending the period three days early prevents an apparent decline at the end of each report.

A practical Google Sheets structure

  1. Settings: Property URL, periods, dimensions, filters, and thresholds.
  2. Current-period data: Raw data without presentation formulas.
  3. Comparison-period data: Use exactly the same columns.
  4. Opportunities: Calculated rows, such as those with high impressions and a low click-through rate.
  5. Dashboard: A concise summary of the most important trends.
  6. Run log: Time, row count, status, and error message.

Script performance

Write data to an entire range at once with setValues() instead of updating cells individually. Do not clear the current report until new data has been fetched successfully. This alone keeps most medium-sized sites comfortably within the six-minute limit.

How to avoid misleading reports

  • Compare periods of equal length and pay attention to seasonality and holidays.
  • Calculate the click-through rate from total clicks ÷ total impressions at the desired level.
  • Distinguish zero values from missing data.
  • Do not present average position as a fixed ranking for every user.
  • Show the date of the last successful run clearly at the top of the dashboard.
  • Send an email alert when a run fails.

When should you move beyond Apps Script?

When you manage multiple sites and destinations (Slack, a task management system, or a database), or repeatedly hit execution limits, move orchestration and alerts to an n8n automation workflow while keeping Google Sheets as an interface for review. To choose which indicators are worth monitoring in the first place, see the technical SEO checklist for ecommerce sites. If you want a report built for your site, contact me.

Is the Search Console data in the report complete?

Not entirely. The Search Analytics API does not guarantee that it will return every row because of internal limits. Some rare queries are also hidden to protect user privacy, so clicks summed across queries may not equal total clicks. Include this caveat at the top of the report.

Is Apps Script free, and can it handle large datasets?

Apps Script is free with a Google account, but it has quotas, including a six-minute limit per execution. For large sites, split requests by date or folder and write data in batches. If you consistently exceed the limits, move to BigQuery bulk export or n8n.

How can I connect Search Console to Google Sheets without coding?

Use the Search Analytics for Sheets add-on or Looker Studio connectors to retrieve data without code. Apps Script gives you more control, including custom schedules, tailored opportunity rules, a run log, and email alerts when a run fails or a significant change occurs.

Can I email the report automatically?

Yes. Use MailApp or GmailApp in Apps Script with a weekly time-driven trigger. Keep the email to a brief summary of the most important changes and include a link to the access-controlled spreadsheet. Do not email sensitive data or attach the entire spreadsheet.

Sources

  1. Google Apps Script — Overview
  2. Apps Script — Quotas and limits
  3. Search Analytics API — query
  4. Apps Script — Authorization for services