Whenever you want to send the data from one place to another the first thing that comes in the mind is Zapier.
We often use Zapier or some other tools like Integromat to send the data from one place to another.
This sometimes gets very expensive and for every task, you have to spend some amount of money.
Today, I am going to tell you how I send the data from my Gravity forms plugin to Google sheet in just a few steps.
Send Data From Gravity Forms to Google Sheets
If you’re planning to send the data from Gravity forms to Google sheet we’re going to use a plugin called Webhooks
This is an add-on that you get if you purchase the premium version of the plugin. If you don’t have the premium version, you don’t have to worry because we have added the download link below.
You might be wondering what is a webhook?
What is a Webhook?
Webhooks helps you to send the data from one app to another.
Webhooks work if you have an open API for the platform.
For example, if you want to send the data from Gravity Forms to Google sheet you can easily do that with a simple trick.
How to Create a Webhook URL?
If you want to send the data from Gravity forms to Google sheets the first thing you need to do is get the webhook URL.
Creating a webhook URL is really simple. You just need to add some code and that’s it.
- Firstly, goto Google sheets and create a new sheet or else click on the link below to create a new Google sheet.
- Add the header of the forms. For example I am going to track Name, Email ID and Message.
- Then copy the URL of your sheet. The URL of the sheet will look something like this.
https://docs.google.com/spreadsheets/d/152PD-6jBXWv0d3BRdCOOCdfI8AbyLyPOtvn3B_O5ZfA/edit#gid=0
- Then you need to copy the id of the google sheet. Whatever comes after /d/ and before /edit#gid=o. Check the below code to know the id of the sheet.
152PD-6jBXWv0d3BRdCOOCdfI8AbyLyPOtvn3B_O5ZfA
- Then click on Tools –> Script Editor
- Then copy paste the code which is given below.
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();
}
- You will need to make the changes in the code now.
- Just change the particular line in your code. Add your spreadsheet ID and the Sheet worksheet name. It will be Sheet 1 or Sheet 2. In my case, it is Sheet 1.
var sheetID = "GOOGLE_SPREADSHEET_ID"; // Replace this with the Google Spreadsheet ID
var sheetName = "Sheet1"; // Replace this with the sheet name inside the Spreadsheet
- Once done then you can click on the Run button
- It will ask you to “Review permission“
- Then you need to login to your Google account and you need to select the account which you use to create the Google sheet.
- Once, done just do the authorization with Google and click on the Allow button. Don’t worry it is safe.
- Once done you need to click on Deploy –> New Deployment
- Click on the Settings and then click on Web App.
- Here you need to make three changes:
- Description: WebVerge Project
- Project Version: 1.0
- Execute the app as: Me ([email protected])
- Who can access to the app: (Anyone)
- Once done you can click on the “Deploy” button.
- Then you will get the current web app URL. You will need to copy this URL and save it somewhere because we will be using this URL.
- The URL will look something like this. Just keep it somewhere safe.
https://script.google.com/macros/s/AKfycbxjjugQU5rymPyRqyDPqhZ8P2Uta3t-CLSDm1CoTFMbezRLPDg/exec
How to Send Data From Gravity Forms to Google Sheets
- Firstly, make sure that you have installed the Gravity Forms plugin on your website.
- Download the webhooks plugin from below.
- Upload the plugin to your website by going to your Dashboard –> Plugins –> Add New –> Upload Plugin
- Activate the plugin
- Once done click on Gravity Forms and edit a form. In the settings you will see a new option of Webhooks.
- You need to click on the “Add New” button to create the workflow.
- Add the Name of the Webhook here. I will add a name and that is Gravity Forms to Google Sheets.
- Do you remember the URL I asked you to keep it safe somewhere? We will need it now.
- Add that URL in the Request URL.
- You will need to make some changes in the settings to send the data to Google sheets.
- Request URL: Paste the URL which we copied and I asked you to keep is safe somewhere.
- Request Method: Post
- Request Format: Form
- Request Header: Don’t touch these settings.
- Request Feilds: Select Fields
- In the field values, there is an option to add Key. You just need to add the header of your Google Sheets here. You can see the screenshot once and you will know.
- If you want to enable the conditional logic you can enable the option. Once done you can click on the save changes button.
- It’s time you test it. Let’s check if everything works fine or not. I will fill the form and test it.
- Once, I click on the submit button. I get the entry in the Google Sheet. That means this trick is working fine for me.
- That’s it! You have successfully sent the data to Google sheets without using any external plugin.
Frequently Asked Questions
Do I need an additional plugin to use this method?
Yes! You will need a Webhook plugin for Gravity forms to get started with the tutorial
Is this Free?
Yes! This is a free trick that will help you to send the data from gravity forms to Google Sheet.
Is there a limit to send the data?
No! There is no limit to sending the data.
Conclusion:
There are a lot of things you can track using this plugin. If you want to capture the user agent, or IP Address you can track that information with the help of this plugin.
There is a little bit of coding which is involved in this method but this nifty trick is working for me.
I have been using this trick from past two years and it is working fine for me.
If you face any issue with this method you can always comment below and I will help you out.
I reply to comments in 8 hours. Let us know if you face any issues.
Damn. You literally saved my 1 hour everyday.
I used to literally copy and paste data from different sheets in order to accumulate, filter, assign to my sales people.
This shall save me a lot of time.
I can use to share meme with you 😂
Hahaha! I am glad you liked the article 😛
The Google Sheets interface has changed a bit, so now you have to go to Extensions > Apps Script instead of Tools > Scripts. Just a suggestion to those who might be looking at this.
Also, somehow I’m not able to get this to work! I followed the steps exactly as they were listed and got the script to run without errors, but it’s still not putting the entries into my Google Sheet 🙁 Any help?
same.
This is really interesting