Google Apps Script · Beginner guide

How It Works: Google Apps Script

Automate Google Sheets, Gmail, Drive, Docs and Forms with reusable scripts. Learn how to find a script, install it, configure it and run it safely.

⏱ Estimated time 5–10 minutes
🎯 Difficulty Beginner friendly
💰 Starting cost Free
🧰 Requirements Google account

What can you automate?

Google Apps Script helps connect Google services and automate repetitive tasks.

📊

Google Sheets

Clean spreadsheet data, generate reports, process rows and create custom menus.

✉️

Gmail

Send email notifications, create mail merges and process messages or attachments.

📁

Drive & Docs

Organise files, generate documents from templates and automate repetitive file tasks.

📝

Forms & Calendar

Respond to form submissions, send notifications and create calendar events.

How to install and run a script

Follow these steps to get a Google Apps Script automation working in your own Google account.

  1. 01

    Find a script

    Browse Google Apps Script resources . Read the description, supported services, requirements and permissions before choosing a script.

  2. 02

    Download the file

    Download the script using the resource page's download option. Files may be provided as .gs, .txt or .zip. Extract ZIP archives before continuing.

  3. 03

    Open the Apps Script editor

    Open the Google Sheet or other supported document you want to automate. Choose Extensions → Apps Script where available, or open script.google.com and create a new project.

  4. 04

    Paste the code

    Review the starter code in the editor and paste the script into the appropriate file. Save the project and give it a descriptive name.

  5. 05

    Configure your settings

    Update any configuration values, such as spreadsheet IDs, tab names, email addresses or Drive folder IDs. Never insert credentials into publicly shared code.

  6. 06

    Run and authorise the script

    Select the appropriate function and click Run. If Google requests authorisation, review the requested permissions and continue only if you trust the script and understand its access.

  7. 07

    Automate with a trigger

    Open the Triggers section in the Apps Script editor and add a supported time-driven or event-based trigger. Check the trigger's limitations and permissions before relying on it.

Safety tip: Make a copy of important files before testing. Run the script on sample data first, and review all requested permissions before authorising it.

Example: Count spreadsheet rows

This simple example reads the active sheet and logs the number of rows below the header. It does not send emails or modify data.

Code.gs Google Apps Script
function countSpreadsheetRows() {
  const sheet = SpreadsheetApp
    .getActiveSpreadsheet()
    .getActiveSheet();

  if (!sheet) {
    throw new Error('No active spreadsheet sheet found.');
  }

  // Assumes the first row contains column headers.
  const lastRow = sheet.getLastRow();
  const dataRows = Math.max(0, lastRow - 1);

  console.log('Rows below the header: ' + dataRows);

  return dataRows;
}
Try it: Open a Google Sheet, select Extensions → Apps Script, paste the example, save it and run countSpreadsheetRows. Check the execution log for the result.

Common trigger types

Triggers allow supported functions to run automatically when a particular event occurs.

Trigger When it runs Example use
Time-driven At a configured time or interval Scheduled reports and reminders
On open When a supported document opens Custom menus and initialisation
On edit When a supported spreadsheet edit occurs Updating timestamps or validating values
On form submit When a supported form submission occurs Notifications and processing responses

Not every trigger is available for every project or service. Consult the official Apps Script documentation for current trigger restrictions and quotas.

Common errors and how to fix them

Check these common causes when a script fails to run.

Error or problem What to check
Authorization required Review the requested permissions and authorise the script only if you trust it.
Cannot read properties of null Check whether the spreadsheet, sheet, document or other expected object is available.
Exceeded maximum execution time Reduce the amount of work per run and process large datasets in smaller batches.
Service invoked too many times Check the relevant service quota and reduce unnecessary calls or trigger frequency.
ReferenceError: X is not defined Check spelling, function names and whether all required code files have been included.

Frequently asked questions

A few things to know before getting started with Google Apps Script.

Do I need to know how to code?

No. Many scripts only require you to copy the code, configure a few settings and run it. More advanced automations may require programming knowledge.

Is Google Apps Script free?

Google Apps Script is available with a Google account. Usage quotas and service limits apply, so check Google documentation for your account and workload.

Why does Google show an app verification warning?

Google may display a warning when an application has not completed verification. Only proceed if you trust the project, have reviewed its code and understand the permissions it requests.

How do I run a script automatically?

Open the Apps Script editor, select Triggers and create a trigger for a supported event or schedule. Some trigger types require additional permissions.

Is it safe to run downloaded scripts?

Review the code, permissions and external requests before running a script. Test it with sample data, protect sensitive information and avoid granting unnecessary access.

Ready to automate your work?

Explore reusable Google Apps Script resources on ZigsFlow, discover helpful examples and find a starting point for your next automation.