Skip to main content

Google Sheets Integration

Append each form submission as a new row in a Google Spreadsheet via a Google Apps Script Web App.

Action type: google_sheets Class: Core_Forms\Actions\GoogleSheets Source: src/actions/class-google-sheets.php

Setup

1. Create the Google Apps Script

  1. Open your Google Spreadsheet.
  2. Go to Extensions > Apps Script.
  3. Replace the default code with a script that accepts POST JSON data and appends rows. Example:
function doPost(e) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var data = JSON.parse(e.postData.contents);
  var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];

  if (headers[0] === '') {
    headers = Object.keys(data);
    sheet.getRange(1, 1, 1, headers.length).setValues([headers]);
  }

  var row = headers.map(function(header) {
    return data[header] || '';
  });

  sheet.appendRow(row);
  return ContentService.createTextOutput('OK');
}

2. Deploy as Web App

  1. Click Deploy > New deployment.
  2. Select type: Web app.
  3. Set Execute as: your account, Who has access: Anyone.
  4. Click Deploy and copy the Web App URL (https://script.google.com/macros/s/.../exec).

3. Configure in Core Forms

  1. Edit your form > Actions tab > Add Action > Add to Google Sheet.
  2. Paste the Web App URL.
  3. Optionally specify which fields to send.

Settings Reference

Setting Required Default Description
Web App URL Yes -- Google Apps Script deployment URL
Fields No All fields Comma-separated list of field names to include

Fields Filter

Leave the Fields setting empty to send all form fields. To send only specific fields:

name, email, phone, message

Only fields matching these names will be included in the JSON payload.

Payload Format

The action sends a JSON POST request with form data as key-value pairs, plus metadata:

{
  "name": "Jane Smith",
  "email": "jane@example.com",
  "message": "Hello",
  "_form_title": "Contact Form",
  "_submitted_at": "2026-04-09 10:30:00"
}
  • Array values (checkboxes) are flattened to comma-separated strings.
  • _form_title and _submitted_at metadata fields are always included.

How It Works

  1. On successful submission, the action collects form data.
  2. If a fields filter is configured, only matching fields are included.
  3. Arrays are flattened to comma-separated strings.
  4. Metadata (_form_title, _submitted_at) is appended.
  5. Data is POSTed as JSON to the Web App URL.
  6. The request times out after 30 seconds (longer than other integrations to accommodate Apps Script cold starts).

Troubleshooting

  • No rows appearing: Verify the Web App URL is the deployment URL (ending in /exec), not the editor URL.
  • Permission errors: Re-deploy with "Anyone" access. The Apps Script must accept anonymous POST requests.
  • Missing columns: Ensure your spreadsheet header row matches the form field names exactly. The _form_title and _submitted_at columns need headers too.
  • Slow responses: Google Apps Script has cold start times. The 30-second timeout accounts for this.