Link Google Forms to Bitly Automatically

2017-11-28 2:36 PM

#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

A thought from Cristian Yuri da Cruz Moreira

2024-01-07 13:50:52

Perdi minha conta Google mais só que não tenho mais meu número de telefone que tá cadastrado ela com faço pra recuperar

A thought from Deleon

2024-03-20 17:45:00

Eu não estou conseguindo recuperar um e-mail

A thought from Brian

2024-03-20 18:39:14

This is such an old post, I'm not sure if this script even works anymore. I seem to remember the bit.ly API changing at some point, but I'm not positive. I fixed the broken link to the source, so that might give you a start.

A thought from Aldeane de Souza Lucas

2024-04-28 16:14:26

Recuperar o acesso

A thought from Brian

2024-04-29 11:46:26

Not sure what you mean - are you trying to recover access to your copy of the sheet? Or to your bitly API key?