/kobo-toolbox-to-google-sheets

Google Apps Script to pull data from Kobo Toolbox to Google Sheets

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

KoboToolbox to Google Sheets: Google Apps Script

Google Apps script to sends a call to KoboToolbox and return data from form submissions to a Google Sheet.

This script has a higher performance than the Google Sheets IMPORTDATA() function (which can lag if lots of data is imported), and eliminates the need for a paid API connection plugin.

Note that this script only works for KoboToolbox projects that do not require authentication to see forms and submit data.

Before starting, rename the sheet to which you want to import the data to 'Data'.

To add to your Google Sheet, open Extensions > Apps Script and paste into Editor > Code.gs.

image

image

In the line with <data_url_csv>, replace this with the URL to make an API call to your KoboToolbox form's data and return it as a CSV. This can be constructed using instructions from: https://support.kobotoolbox.org/synchronous_exports.html.

A custom menu will appear with a menu item to run the script.

image

Note that the KoboToolbox server needs up to 5 mins to make collected data from a project available through the API, so a slight lag may be experienced between form submissions and this being able to be pulled into the Google Sheet.

The script can also can be set to a scheduler within Google Apps Script to automatically import data at a set time interval. To do so, open Extensions > Apps Script and go to Triggers. Select Add Trigger.

image

Update the modal as follows:

image

Then choose your update interval and Save:

image