Random redirector

This tool currently runs through my old mathstatic.co.nz website. At some stage I’ll move it onto this statistics-is-awesome.org website 🙂

This tool is similar to the wide range of URL shorteners out there e.g. goo.gl, tiny.cc, bit.ly etc., except that the shortened URL will send you to one of two links at random. I couldn’t find anything like this out there when I searched (but I may have been using the wrong search words!) which is why I set up this tool. [Edit: Scroll down to the bottom to learn how to set up your own random redirects using Google App Scripts]

It is useful in particular for online experiments, where you want to send participants to one of two different pages (e.g. a Google survey) without them necessarily being aware of this randomisation process.

To setup the URL, head to http://mathstatic.co.nz/auto and follow the instructions on the page.

Set up the random redirect URL

Want to set up your own random redirects without using my tool?

Awesome! Here is something you could do using Google App Scripts.

  1. Under Google Drive, create a new Google Apps Script (you might have to look under “More” after you click the “New” button).
  2. Give your project a name e.g. Random redirect
  3. In the Code.gs tab, delete what is there and replace with this code.
  4. Replace the links to the Google forms with your own 🙂
  5. Save the project then select “Deploy as web app” from the “Publish” menu. Under “Who has access to the app” select “Anyone, even anonymous”.

You should then get a “Current web app URL:” that looks something like this: https://script.google.com/macros/s/AKfycbwu_Fv8gGGbzMCqot1e1-u8TereYJ9uJVfIMw02NxNUTj9WNII/exec

You can then give people this URL (or use a URL shortener first to make it look nicer e.g. https://goo.gl/​, or embed it in an existing webpage), and it will randomly redirect them to one of the Google forms you’ve added to the code.