Insights and Inspiration – The Hostnicker Blog

Integrating Webflow Forms with Google Sheets

September 18, 2024

Step 1: Set Up Your Webflow Form

1. Log in to your Webflow account and open the project where you want to add the form.
2. Navigate to the page where you want the form to appear. Either create a new page or edit an existing one.
3. Drag the Form Block from the Add panel on the left onto your canvas. Customize the form by adding input fields such as text, email, checkbox, or dropdown, depending on the information you want to collect.
4. Ensure each input field is clearly named to help you identify responses in Google Sheets later.
5. Optionally, add a Submit button for users to click to submit their data.

Step 2: Obtain Your Google Sheets API Key and Set Up a Trigger

1. Visit the Google Cloud Console.
2. If you don’t have a project yet, click on the Select a Project dropdown and choose New Project. Name your project and click Create.
3. In the side menu, click on APIs & Services, then Library. Search for Google Sheets API and enable it for your project.
4. Go to Credentials in the side menu. Click Create Credentials and choose API Key. Copy your newly generated API key, as you will need it later.
5. To set up a trigger, open Google Sheets and create a new spreadsheet. Name it appropriately.
6. Click on Extensions in the menu and select Apps Script. Replace any code in the script editor with this code snippet:

```javascript
function doPost(e) {
const sheet = SpreadsheetApp.openById('your-spreadsheet-id').getActiveSheet();
const data = JSON.parse(e.postData.contents);

sheet.appendRow([data.field1, data.field2, data.field3]); // Adjust according to your fields
}
```

7. Replace 'your-spreadsheet-id' with your actual Google Sheets ID, found in the URL of your sheet.
8. Save the project and click on the clock icon (Triggers) in the left sidebar. Click Add Trigger and configure it to run the doPost function with the event source set to From web. Save the trigger.

Step 3: Implement Form Submission via Webflow

1. In Webflow, return to your form settings and locate the Action field.
2. Replace the current action URL with the URL of your Google Apps Script web app. To get this URL, go back to your Apps Script project, click on Deploy, then New deployment.
3. Choose Web App as the deployment type, set Who has access to Anyone, and click Deploy. Authorize any required permissions.
4. Copy the URL provided after deployment. This is where form data from your Webflow site will be sent.
5. Paste this URL into the Action field in your Webflow form settings.

Step 4: Test Your Integration

1. Publish your Webflow site to make the changes live.
2. Visit your website, fill out the form, and submit a test response.
3. Open your Google Sheets spreadsheet and check that the data appears in the designated columns.

Step 5: Customize and Manage Your Data

1. Customize your Google Sheets to format data, add formulas, or create charts to visualize collected information.
2. Regularly monitor the sheet to ensure all data submissions are recorded correctly.
3. Use Google Sheets features like filters, conditional formatting, or data validation to dynamically analyze responses.

By following these steps, you can effectively integrate Webflow forms with Google Sheets, streamlining your data collection and management process. This approach saves time and provides a powerful way to systematically analyze user input for better decision-making.