How to create online survey for free with SurveyJS and Google Sheets | by Rafał Rybnik | Dec, 2020


SurveyJS works on the browser side. You have to store answers from your respondents in some database. Our main goal in collecting the results (answers from your respondents) in the database. We will use Google Sheets. To do this, we need to capture data from POST requests from SurveyJS and insert them as rows in a spreadsheet.

First, create a new spreadsheet in Google Sheets. It will be your data storage. In the first sheet, add header row, with columns datetime, raw_data and rate. Header row should contain names of all questions to which you wish to save the answers. Columns datetime and raw_data will be automatically filled by script. To create code, click on Tools > Script editor.

Cell formatting isn’t necessary but increases readability.

New App Script project will be created.

Note: Google currently is switching App Script to the new editor. It doesn’t matter which version of the editor you use. Commands and options could be in different places, but they are mostly the same.

Paste code below to the file.

Next, you must set up your script for working with a spreadsheet created before. Click on Run > setup.

Note: in the new interface, you should select the setup function from the dropdown menu and click play button.

After that, you probably will be asked for granting your app permission to access Sheets’ data. Alternatively, you can hard code spreadsheet id (look into comments in code).

You can get the id sheet from its URL.

Finally, deploy your new app by clicking Publish > Deploy as web app. Importantly, you need to set options:

  • security level: “Anyone, even anonymous”,
  • execute as: “me”.

Copy web app URL. We will need it in the next section.

Read More …


Write a comment