Link Google Forms to Bitly Automatically

Published: 2017-11-28 2:36 PM | Updated: 2024-03-20 2:42 PM

Category: Code | Tags: google apps script, javascript


Note 2024-03-20 - This post has been updated with a correct video embed as well as a GitHub Gist link for the source code. The code has not been tested since ~2018. Any changes to th Bit.ly API since that time are not accounted for in this script.

If you have a bit.ly account, you can get a public API token which can be used to create shortcodes. This is really handy in my situation, where I’m creating a ton of feedback spreadsheets (another monster post on that later). Using a small code snippet, you can create a feedback form, throw in some code, and have it display as a short URL and QR code.

If you’re starting from scratch, create a template form and spreadsheet. When you need to make a feedback form, use File > Make a copy on the spreadsheet to copy over the code.

Otherwise, you can make a copy of this blank template to get started (code is already inserted). If you’re going to make your own, be sure you have a form linked. If there is no form on your sheet, you’ll get an error.

The code

The full source code is shared in a GitHub Gist. Note that there are two files: one called Code.gs and one called popup.html. If you’re copying/pasting, you need to create an HTML file (File > New > Html file in the script editor) and call it ‘popup’.

In action

The wheels of the web keep spinning…

Share this post
Previous: Slides Tweeter Update 2 Next: Slides Tweeter Update 3

Comments