Google forms can be handy for creating an easy way to add new data to a spreadsheet. And you can also set them up to post to a Beeminder goal, too.
- Create a new form in Google Drive and edit it.
- Click the three vertical dots in the top right of the screen and select “Script editor.”
- Copy the following code into the script, and replace the placeholders with your values:
function onSubmit() {
const url = "https://www.beeminder.com/api/v1/users/[ USERNAME ]/goals/[ GOAL NAME ]/datapoints.json?auth_token=[ API TOKEN ]"
const options = {
method: 'post',
contentType: 'application/json',
payload: JSON.stringify({ value: 1 })
}
UrlFetchApp.fetch(url, options)
}
- Save the script.
- Click the Run or Play button in the toolbar.
- Grant permissions when requested.
- Check that the function worked and posted to your goal.
- In the left sidebar select “Triggers.”
- Click “Add trigger” in the bottom right of the screen.
- Select “On form submit” in the type menu.
- Save out of the dialog.
- If requested, grant additional permissions.
You’re done! From now on, submitting your form will add a datapoint to your Beeminder goal.
Reference: