TownHall + Google Sheets Integration
Automatically log all form submissions to Google Sheets. Create a live database of responses without any manual data entry.
Features
How to set up
Create a Google Sheet
Create a new Google Sheet where submissions will be logged.
Set Up Apps Script
Go to Extensions → Apps Script and paste our webhook handler code.
Deploy as Web App
Deploy the script as a web app and copy the deployment URL.
Add to TownHall
Paste the Google Apps Script URL as a webhook in TownHall.
Code example
// Google Apps Script for TownHall webhook
function doPost(e) {
const sheet = SpreadsheetApp.getActiveSheet();
const data = JSON.parse(e.postData.contents);
// Get or create headers
let headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
if (headers[0] === '') {
headers = ['Timestamp', 'ID', ...Object.keys(data.submission.data)];
sheet.getRange(1, 1, 1, headers.length).setValues([headers]);
}
// Add new row
const row = headers.map(h => {
if (h === 'Timestamp') return new Date().toISOString();
if (h === 'ID') return data.submission.id;
return data.submission.data[h] || '';
});
sheet.appendRow(row);
return ContentService.createTextOutput(JSON.stringify({success: true}));
}Use cases
Related integrations
Zapier
Connect TownHall to 5,000+ apps through Zapier. Automate workflows, sync data, a...
automationMake (Integromat)
Build sophisticated automations with Make (formerly Integromat). Create multi-st...
storageAirtable
Add form submissions to Airtable bases automatically. Combine the power of sprea...