You can use the free Gravity Forms Post to 3rd Party API plugin to send your Gravity Forms submission data to just about any third-party API. One of those APIs that’s dead simple to post to is Google Sheets. Here’s how I sent my data from Gravity Forms to Google Sheets in 5 minutes:
Create your Google spreadsheet and add your header row to the spreadsheet
Go to Tools->Script editor to add a new Google script
Remove anything that’s currently in the editor, and copy and paste the following code, being sure to replace the sheet ID and the sheet name
The spreadsheet ID is the long sequence of characters between the slashes in the URL of the desired spreadsheet:
docs.google.com/spreadsheets/d/1WcdRWIKAslZELefW27HDFQ0JW585Q9jJCvckS7H24ab/edit?usp=sharing
function doPost(e) { if (!e) return; var sheetID = "GOOGLE_SPREADSHEET_ID"; // Replace this with the Google Spreadsheet ID var sheetName = "Sheet1"; // Replace this with the sheet name inside the Spreadsheet var status = {}; // Code based on Martin Hawksey (@mhawksey)'s snippet var lock = LockService.getScriptLock(); lock.waitLock(30000); try { var sheet = SpreadsheetApp.openById(sheetID).getSheetByName(sheetName); var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0]; // Add the data and time when the Gravity Form was submitted var column, row = [], input = { "timestamp": new Date() }; for (var keys in e.parameter) { input[normalize_(keys)] = e.parameter[keys]; } for (i in headers) { column = normalize_(headers[i]) row.push(input[column] || ""); } if (row.length) { sheet.appendRow(row); status = { result: "success", message: "Row added at position " + sheet.getLastRow() }; } else { status = { result: "error", message: "No data was entered" }; } } catch (e) { status = { result: "error", message: e.toString() }; } finally { lock.releaseLock(); } return ContentService .createTextOutput(JSON.stringify(status)) .setMimeType(ContentService.MimeType.JSON); } function normalize_(str) { return str.replace(/[^\w]/g, "").toLowerCase(); }
Save your script
Run your script to authorize it
Deploy the script so that we can get the script URL to post to
Copy the current web app URL from the confirmation screen
Create a new Send to Third Party feed for your form, select the POST method, paste the web app URL into the API URL field, set the Authorization to None, and map your form fields to your spreadsheet header columns
Submit the form and you’ll see the new entry and the information added to your spreadsheet
So if there isn’t an add-on available off-the-shelf, and you don’t want to use Zapier or it isn’t quite working right for your API, use the Gravity Forms Post to 3rd Party API plugin 🙂
Questions? Email me