Skip to main content
  • For: treasurers and whoever runs the website
  • You get: a thermometer on your website that fills as donations come in, with no key in the website’s code
  • Time: about fifteen minutes
  • Scopes: fundraising:read
This recipe puts a fundraising thermometer on your group’s website: a bar that fills as donations come in, with the total raised and the target. It updates itself as people give through Scoutworks. It has two parts, and it takes about fifteen minutes:
  1. A Google Sheet that reads your campaigns from Scoutworks every hour.
  2. A small piece of HTML on your website that reads the sheet.
Never put an API key in your website’s code. Anyone can read a web page’s code, so a key there is public. The website reads only a published sheet of totals. The key stays in the sheet’s script, in Script Properties, where visitors cannot see it.

1. Fill a sheet with your campaigns

In a new Google Sheet, choose Extensions → Apps Script. Delete what is there, paste the script below and choose Save.
Code.gs
Then:
1

Add your key

Choose Project Settings (the cog), then Script Properties → Add script property. Property: SCOUTWORKS_API_KEY. Value: the sandbox key to try it, or your own key.
2

Run it

Choose updateTotals and press Run. Open the Totals tab. Each campaign has a row, found by its slug: the last part of the campaign’s address on your donate page.
3

Refresh it every hour

Choose Triggers (the clock), then Add Trigger. Function: updateTotals. Event source: Time-driven. Type: Hour timer. Every: hour.

2. Publish the totals tab

In the sheet, choose File → Share → Publish to web. Under Link, choose the Totals tab (not Entire document) and Comma-separated values (.csv). Choose Publish and copy the address. The published tab holds only campaign totals: no donor names, no amounts of single gifts and no key. Google updates a published sheet within about five minutes of a change.

3. Add the thermometer to your website

Paste this where the thermometer should go. Change the two lines at the top: the address you copied, and your campaign’s slug.
Thermometer
Most website builders take this in an HTML, Embed or Code block. Change the bar’s colour to match your site.

4. Switch to your group

In the script, change api-demo.scoutworks.app to api.scoutworks.app, and replace the sandbox key with your own. Your key needs the fundraising:read scope. Give it no other scope. In the snippet, change CAMPAIGN to your own campaign’s slug.

Notes

  • The total matches Scoutworks. It counts paid donations only, without Gift Aid added.
  • A campaign with no target shows the total raised and no bar.
  • How fresh. The sheet reads Scoutworks every hour, and Google publishes the change within about five minutes. A donation reaches the thermometer within about an hour.
  • Your own server instead. If your website has its own server, it can call GET /fundraising-campaigns itself, keep the key in its settings, and pass only the totals to the page. The rule is the same: the key never reaches the browser.