Features
- Automatic Sync: Each submission is instantly added as a new row
- Column Mapping: Form fields are automatically mapped to spreadsheet columns
- Header Management: Column headers are automatically created and updated
- Hidden Fields: Option to include hidden fields in the spreadsheet
- File Support: File upload fields include signed URLs to access uploaded files
Prerequisites
- A Google account
- Permission to create/edit spreadsheets in Google Drive
Setup
Add Google Sheets Integration
In your form editor:
- Go to Integrations tab
- Select Google Sheets
- Click Connect Google Account
Authorize OpnForm
- Sign in to your Google account
- Grant OpnForm permission to access Google Sheets
- You’ll be redirected back to OpnForm
Create or Select Spreadsheet
Choose one of the following:Option A: Create New Spreadsheet
- Click Create New Spreadsheet
- A new spreadsheet with your form name will be created
- Column headers will be automatically added
- Click Select Existing Spreadsheet
- Choose a spreadsheet from your Google Drive
- Select the worksheet tab to use
Configure Column Mapping
- OpnForm automatically maps form fields to spreadsheet columns
- You can reorder or remove columns as needed
- Column headers are created from field names
How It Works
Initial Setup
When you create a Google Sheets integration:- OAuth Connection: OpnForm connects to your Google account using OAuth 2.0
- Spreadsheet Creation: A new spreadsheet is created (or you select an existing one)
- Column Mapping: Form fields are mapped to spreadsheet columns
- Headers Set: First row contains field names as headers
On Each Submission
When a form is submitted:- Header Sync: Column headers are updated if form fields changed
- Data Formatting: Submission data is formatted for spreadsheet insertion
- Row Addition: A new row is appended with the submission data
- File URLs: File uploads are converted to signed URLs
Column Mapping
Form fields are automatically mapped to spreadsheet columns:| Form Field Type | Spreadsheet Value |
|---|---|
| Text, Email, Phone | String value |
| Number | Numeric value |
| Date | Date string |
| Select (dropdown) | Selected option |
| Multi-select | Comma-separated values |
| File Upload | Signed URL to file |
| Checkbox | ”Yes” or “No” |
| Hidden Field | String value (if enabled) |
Hidden Fields
By default, hidden fields are included in the spreadsheet. You can configure this in the integration settings.Implementation Details
OAuth Integration
The Google Sheets integration requires OAuth authentication to access your Google account. Fromapi/app/Integrations/Handlers/GoogleSheetsIntegration.php:31-34:
Spreadsheet Manager
TheSpreadsheetManager class handles all interactions with Google Sheets API.
From api/app/Integrations/Google/Sheets/SpreadsheetManager.php:49-65:
Submission Handler
When a submission occurs, data is formatted and appended to the spreadsheet. Fromapi/app/Integrations/Google/Sheets/SpreadsheetManager.php:145-156:
Building Rows
Submission data is formatted to match the column order: Fromapi/app/Integrations/Google/Sheets/SpreadsheetManager.php:130-143:
Token Refresh
Google OAuth tokens expire after a certain time. OpnForm automatically refreshes tokens when needed. Fromapi/app/Integrations/Google/Google.php:37-59:
Spreadsheet Structure
Example Spreadsheet
| Name | Phone | Message | Priority | Submitted At | |
|---|---|---|---|---|---|
| John Doe | [email protected] | 555-0123 | Looking for info | High | 2024-03-05 12:34:56 |
| Jane Smith | [email protected] | 555-0456 | Need support | Medium | 2024-03-05 13:45:12 |
Column Headers
Headers are automatically created from form field names and updated when form fields change:Conditional Logic
You can configure the Google Sheets integration to only add rows when certain conditions are met:- Only add to spreadsheet when “Status” is “Approved”
- Filter based on priority level
- Exclude test submissions
Troubleshooting
Data not appearing in spreadsheet
Data not appearing in spreadsheet
Check OAuth connection: Re-authorize Google account if neededVerify spreadsheet access: Ensure the spreadsheet hasn’t been deletedCheck conditional logic: Ensure conditions are met for rows to be addedReview integration logs: Check Form Settings → Integrations → Google Sheets → View Events
Columns not matching form fields
Columns not matching form fields
Update column mapping: Edit the integration and rebuild columnsCheck for custom blocks: Custom blocks (starting with
nf-) are automatically skippedRefresh headers: The integration automatically updates headers on each submissionFile URLs not working
File URLs not working
Signed URLs expire: File URLs are signed and expire after a certain timeDownload files: Download files immediately if long-term access is neededCheck permissions: Ensure files are properly stored and accessible
OAuth token expired error
OAuth token expired error
Automatic refresh: Tokens are automatically refreshed by OpnFormRe-authorize: If refresh fails, remove and re-add the Google accountCheck refresh token: Ensure the OAuth provider has a valid refresh token stored
Duplicate rows appearing
Duplicate rows appearing
This can happen if:
- Integration is added multiple times to the same form
- Form is submitted multiple times
- Multiple integrations point to the same spreadsheet
Limitations
Best Practices
Use Dedicated Spreadsheets
Create a separate spreadsheet for each form instead of using multiple sheets in one file. This improves performance and organization.
Regular Backups
Periodically download your spreadsheets as backups. While data is stored in Google Drive, having local copies is recommended.
Clean Field Names
Use clear, concise field names in your form as they become column headers:
- ✅ “Customer Email”
- ✅ “Phone Number”
- ❌ “email_field_123”
Limit Hidden Fields
Only include hidden fields if necessary. They add extra columns that may clutter your spreadsheet.
Privacy Considerations
Advanced: Manual Spreadsheet Setup
If you prefer to manually set up your spreadsheet:- Create a spreadsheet in Google Sheets
- Add column headers in the first row matching your form field names
- Share the spreadsheet with OpnForm’s service account
- Note the spreadsheet ID from the URL
- Contact support to manually configure the integration
Related Resources
- Google Sheets API Documentation
- OAuth 2.0 Overview
- OpnForm Webhooks (alternative for custom storage)