Ad & Integrations > Webhooks
Webhooks + Google Sheets
Use a SuperFunnel webhook and a Google Apps Script to automatically log form submissions into a Google Sheet.
Overview
This guide walks through connecting a SuperFunnel webhook to a Google Sheet so that every form submission is automatically logged as a new row. A Google Apps Script acts as the receiver: it accepts the POST request from SuperFunnel, reads every field in the submission dynamically, and writes them to the sheet — including adding new columns automatically as your forms evolve.
Prerequisites
Prerequisites: - A SuperFunnel webhook configured to send New Lead events (Webhooks guide) - A Google account with access to Google Sheets and Google Apps Script
Part 1: Create a Google Sheet
Create a new spreadsheet
Go to sheets.google.com and create a new spreadsheet.
You can type sheets.new into your address bar to quickly create a Google Sheet.
Name it
Give it a descriptive name (e.g., "SuperFunnel Leads").
Leave the first row empty
Leave row 1 empty — the script will write column headers there automatically on the first submission.
Part 2: Open the Apps Script Editor
Open the editor
In your Google Sheet, click Extensions > Apps Script.
Clear the placeholder code
Delete any existing code in the editor.
Paste the script
Paste the following script:
function doPost(e) {
try {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var payload = JSON.parse(e.postData.contents);
var leadData = payload.data;
var formData = leadData.form || {};
// Build a flat record: fixed metadata columns first, then all form fields
var record = {
"Timestamp": new Date().toISOString(),
"Form Name": leadData.formName || "",
"Submission ID": leadData.submissionId || "",
"IP Address": leadData.ip || ""
};
// Dynamically include every field present in the submission
for (var key in formData) {
if (formData.hasOwnProperty(key)) {
var field = formData[key];
record[key] = field && field.value !== undefined ? field.value : "";
}
}
// Read existing headers (row 1), or start with an empty list
var lastCol = sheet.getLastColumn();
var headers = lastCol > 0
? sheet.getRange(1, 1, 1, lastCol).getValues()[0]
: [];
// Append a header column for any field not yet in the sheet
var keys = Object.keys(record);
keys.forEach(function (k) {
if (headers.indexOf(k) === -1) {
headers.push(k);
sheet.getRange(1, headers.length).setValue(k);
}
});
// Write the row in the same order as the headers
var row = headers.map(function (h) {
return record.hasOwnProperty(h) ? record[h] : "";
});
sheet.appendRow(row);
return ContentService
.createTextOutput("Success")
.setMimeType(ContentService.MimeType.TEXT);
} catch (err) {
return ContentService
.createTextOutput("Error: " + err.toString())
.setMimeType(ContentService.MimeType.TEXT);
}
}Save the project
Click Save (or press Cmd/Ctrl + S) and give the project a name when prompted.
Works with any form
This script is form-agnostic. It reads every field from the submission and
creates a new column automatically if one doesn't exist yet — so it works
across all your forms without any code changes.
Use our agent if you need to adjust the script to fit your specific needs or
data structure.
Part 3: Deploy as a Web App
Open the deployment dialog
Click Deploy > New deployment in the Apps Script toolbar.
Configure deployment settings
- Set Type to Web app.
- Set Execute as to Me — this gives the script permission to write to your sheet.
- Set Who has access to Anyone — this allows SuperFunnel's servers to reach the endpoint.
Access must be set to Anyone
Anyone (not "Anyone in your organization") is required. If access is restricted to your organization, SuperFunnel will not be able to POST to the URL and no data will arrive.
Authorize the script
Click Deploy. Google will ask you to authorize the script to access your spreadsheet. Click through the prompts and grant access.
Copy the Web App URL
After deployment, Google displays a Web App URL. Copy it — you will paste it into SuperFunnel in the next part.
The URL changes per deployment
The Web App URL changes every time you create a new deployment. If you click Deploy > New deployment again in the future, you will receive a different URL and must update it in SuperFunnel. To avoid this, update your existing deployment instead of creating a new one — see Updating the Script below.
Part 4: Enter the URL in SuperFunnel
This is a repeat of the final steps in the Webhooks guide but with specific instructions for Google Sheets.
Open Integrations
In SuperFunnel, click Settings > Integrations.
Open or create a webhook
Open your existing webhook, or create a new one following the Webhooks guide.
Paste the Web App URL
Paste the Web App URL into the URL field.
Set the event type
Set the event type to New Lead so the sheet only receives completed form submissions, not every page view.
Save
Click Save.
Part 5: Test the Connection
Open a published page
Navigate to one of your published pages.
Submit the form
Fill out the form with test data (e.g., test@example.com) and submit it.
Check your sheet
Open your Google Sheet — a new row should appear within a few seconds containing a timestamp, form name, submission ID, IP address, and all submitted field values.
If no row appears, see Troubleshooting below.
Updating the Script
When you need to change the script later, update your existing deployment rather than creating a new one — this keeps the Web App URL stable.
Edit and save the script
Make your changes in the Apps Script editor and save.
Open Manage Deployments
Click Deploy > Manage deployments.
Update the existing deployment
Click the pencil icon next to your deployment, set Version to New version, and click Deploy. The URL remains the same.
Troubleshooting
- No row appeared in the sheet — Confirm the Web App is deployed with access set to Anyone. Re-test by submitting the form again and waiting 10–15 seconds.
- URL mismatch — If you created a new deployment, copy the new Web App URL and update it in SuperFunnel under Settings > Integrations.
- Authorization error — Re-open the Apps Script editor, click Deploy > Manage deployments, and verify the deployment is active. Re-authorize if prompted.
- Some fields are missing — Ensure the event type in SuperFunnel is set to New Lead and that the form fields have values. Empty fields are stored as blank cells, not omitted.
- Need help? — Contact support at
support@superfunnel.ai.