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.
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.
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.
Update the modal as follows:
Then choose your update interval and Save: