Send form submissions directly to a Google Sheets spreadsheet.
Setup Steps
Create a Google Sheet
- Go to Google Sheets
- Create a new spreadsheet
- Add column headers in the first row matching your form fields
- Example:
Name, Email, Message, Submitted At
Create a Google Apps Script
- In your spreadsheet, go to Extensions → Apps Script
- Delete any existing code
- Paste the following script:
function doPost(e) {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const data = JSON.parse(e.postData.contents);
// Get headers from first row
const headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
// Create row based on headers
const row = headers.map(header => {
const key = header.toLowerCase().replace(/\s+/g, '_');
return data[key] || data[header] || '';
});
// Add timestamp if column exists
const timestampIndex = headers.findIndex(h =>
h.toLowerCase().includes('submitted') || h.toLowerCase().includes('timestamp')
);
if (timestampIndex !== -1) {
row[timestampIndex] = new Date().toISOString();
}
sheet.appendRow(row);
return ContentService.createTextOutput(JSON.stringify({success: true}))
.setMimeType(ContentService.MimeType.JSON);
}
Deploy the Script
- Click Deploy → New deployment
- Click the gear icon → Web app
- Set Execute as: “Me”
- Set Who has access: “Anyone”
- Click Deploy
- Authorize the app when prompted
- Copy the Web app URL
Configure in Spike
- Go to your Spike Dashboard
- Select your form → Settings
- Scroll to Integrations → Google Sheets
- Enable the toggle
- Paste your Apps Script Web app URL
- Save changes
Column Mapping
The script automatically maps form fields to columns:
| Form Field | Column Header |
|---|
name | Name |
email | Email |
message | Message |
| Any field | Matching header |
Column headers are case-insensitive and spaces are converted to underscores for matching.
Adding a Timestamp
Add a column called “Submitted At” or “Timestamp” to automatically record when each submission was received.
Troubleshooting
- Verify the Apps Script URL is correct
- Check that the script is deployed as a web app
- Ensure “Anyone” has access to the web app
- Check the Apps Script execution logs for errors
- Column headers must match form field names
- Headers are case-insensitive
- Spaces in headers are matched to underscores in field names
- Re-deploy the script and re-authorize
- Make sure you’re using the correct Google account
Advanced: Custom Field Mapping
Modify the Apps Script to customize how fields are mapped:
function doPost(e) {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const data = JSON.parse(e.postData.contents);
// Custom mapping
const row = [
data.name || '',
data.email || '',
data.phone || '',
data.message || '',
new Date().toISOString()
];
sheet.appendRow(row);
return ContentService.createTextOutput(JSON.stringify({success: true}))
.setMimeType(ContentService.MimeType.JSON);
}