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
- Open your Google Spreadsheet.
- Go to Extensions > Apps Script.
- 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
- Click Deploy > New deployment.
- Select type: Web app.
- Set Execute as: your account, Who has access: Anyone.
- Click Deploy and copy the Web App URL (
https://script.google.com/macros/s/.../exec).
3. Configure in Core Forms
- Edit your form > Actions tab > Add Action > Add to Google Sheet.
- Paste the Web App URL.
- 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_titleand_submitted_atmetadata fields are always included.
How It Works
- On successful submission, the action collects form data.
- If a fields filter is configured, only matching fields are included.
- Arrays are flattened to comma-separated strings.
- Metadata (
_form_title,_submitted_at) is appended. - Data is POSTed as JSON to the Web App URL.
- 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_titleand_submitted_atcolumns need headers too. - Slow responses: Google Apps Script has cold start times. The 30-second timeout accounts for this.