CMS

Integration of Drupal Webforms with Google Sheets using Zapier

Webform is the module to create forms and to make surveys in Drupal. A Webform can be a  basic contact us form with a few fields such as name, phone, and email, or it can also be used to create complex multi-page forms with conditional fields. After submission, the results will be stored in the database . The submission results can be sent through customizable emails to administrators and/or submitters..

Now what if, we want to export the submission result into a  spreadsheet application without writing any custom code or by calling the correct  API’s. This can be done in a simple way using a service called ZAPIER.

In this blog, we will learn how to send Webform submissions into Zapier which will then add it as a row into a Google Sheets.

What is Zapier?

Zapier is an online automation tool that connects to your favorite apps, such as Gmail, Slack, MailChimp, and over 1,000 more. For example, maybe you get a lot of email attachments in your Gmail account and you want to save them to Dropbox. Every time you get an attachment, you could open up the email, click on the attachment, and then save it to Dropbox. Or you can have Zapier automate this for you, saving you time and effort.

 

Submissions are sent to Zapier using a POST request that can be configured by adding a “Remote post” handler to a form. When a submission gets added, Webform will send it via a POST request using the URL in the “Remote post” handler.

Getting Started

Download the Webform module into the modules folder of the root directory and install Webform and Webform UI. We’ll use the default Contact form that comes with the module.

Before getting into Zapier, we will know some common terms used in Zapier.

Zap

A Zap is an automated workflow between your apps. For example, you may have a Zap that saves your Webform Submissions as a row into the Google Sheets. Zaps consist of at least two parts: a Trigger and one or more Actions.

Trigger

A Trigger is an event in an app that starts the Zap. Once you set up a Zap, Zapier will monitor the app for that event.

Action

An Action is the event that completes the Zap. For the Webform Submission example, the action is updating the spreadsheet row  with Webform data on submission.

Task

Each piece of data you run through your Zap counts as a task.

Create a Zapier Account

Now you are ready to start creating Zaps. The first thing you will need to do is sign up for a free account.

picture once you login.

Step 1: Create Zap on Zapier

1. Click on “Make a Zap!” in the top right.

2. In the “Choose a Trigger App” page, click on Webhooks in the “Built-in Apps” section down the page.

3. Choose “Catch Hook” and click “Save + Continue”.

4. Click Continue on the “Pick off a Child Key” page.

5. Copy the POST url because we’ll need it for Webform.

Step 2 : Set up Remote Post Handler

Using the POST url from Zapier which we got in the last section, we’ll need to create a “Remote post” handler in Webform.

1. Go to Structure, Webforms and click on Settings on a Webform. For this tutorial, I’ll use the default Contact form that comes with Webform.

2. Click on the “Emails / Handlers” tab, then click on “Add handler”.

3. Click on “Add handler” on the “Remote post” row.

4. In the Completed section paste the URL that we have got from Zapier and click on Save.

Step 3: POST Test data to Zapier

Go to your Zap again,

1. Once you’ve configured the “Remote post” handler click on “Ok, I did this”.

2. Now go back to your Drupal site and submit the actual form so it sends a POST to Zapier. This is a required step.

3. Once you’ve sent a test POST, you should be on the “Pick A Sample To Set Up Your Zap” section. You can view what was in the post by clicking on the down arrow.

When you’re ready,click on Continue.

Step 4: Configure Google sheets in Zapier(Action)

Now we need to configure the action; where the submission data of the webform will be stored.

1. Click on Google Sheets on the “Choose an Action App”.

2. Choose “Create Spreadsheet Row” and click on “Save + Continue”.

3. Choose an account that is already connected to Zapier or click the “Connect a New Account” button to add a new account, then click on “Save + Continue”.

4. From the Spreadsheet field select the actual spreadsheet you want the submissions saved into.

5. Select the Worksheet within the spreadsheet.

If you see the message below it means your spreadsheet doesn’t have any headers.

Go and add a header for each column you want to save in your Google Sheets spreadsheet.

6. Now go and map the fields with the values below the “Catch Hook”. Then click on Continue.

7. Click on “Send Test to Google Sheets” to test everything out.Check your Google Sheets you should see a new row in it.

Then click on Finish.

8. Don’t forget to name and Zap and switch it on.

Step 5: Webform Submission

Go to your Webform and create an actual submission. Once submitted you should see the submission as a row in the spreadsheet.

Conclusion

This blog provides a simple way to generate reports in the spreadsheets using WebForm and Zapier.

About The Author

Leave a Reply

*