Send form submissions to Google Sheets

Add a row to a Google Sheet for every form submission, using a small script that lives in your own sheet. No third-party automation tool and no access to your Google account is given to anyone.

What you need

  • A FormTango form on a paid plan. Any HTML form works; see the guides.
  • A Google Sheet
  • Two minutes to paste a script into it

Set it up

  1. 1

    In your sheet, open Extensions → Apps Script, delete what is there and paste the script below.

  2. 2

    Click Deploy → New deployment, choose "Web app", set "Who has access" to "Anyone", and deploy. Copy the web app URL.

  3. 3

    Open your form in FormTango and go to the Connections tab. Choose Webhook and paste the web app URL.

  4. 4

    Click "Send test" to check it, then submit your form for real.

apps script
function doPost(e) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
  var data = JSON.parse(e.postData.contents).data;
  var fields = data.fields;

  // The first submission writes the header row.
  if (sheet.getLastRow() === 0) {
    sheet.appendRow(['Received'].concat(Object.keys(fields)));
  }
  var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];

  // New fields get a new column, so nothing is dropped.
  Object.keys(fields).forEach(function (key) {
    if (headers.indexOf(key) === -1) {
      headers.push(key);
      sheet.getRange(1, headers.length).setValue(key);
    }
  });

  var row = headers.map(function (header) {
    return header === 'Received' ? data.createdAt : (fields[header] || '');
  });
  sheet.appendRow(row);
  return ContentService.createTextOutput('ok');
}

Good to know

  • The web app URL works like a password for adding rows: anyone who has it can add a row. Keep it private. FormTango never shows it again after you save it.
  • Columns are created from your field names the first time each one appears.
  • Prefer a file? Every plan with exports can download all submissions as CSV at any time.

More integrations

SlackDiscordMicrosoft TeamsTelegramNotionAirtableMailchimpHubSpotKit (ConvertKit)Webhooks