Gamify your classroom with Google Forms

Gamification and badges in education have been ideas floating around for a few years now. Some educators have jumped on the band wagon only to abandon the concept soon after. Often, one of the obstacles to effective implementation is proper technological support (1). The good news is Google Forms is a relatively simple (and free!) tool to help implement gamification elements into education.

What are “badges” & “gamificationGamification and badges in education using Google Forms“?

Badges in education and the idea of gamification is one way teachers can help motivate students in the classroom and help students keep track of effort and achievement.

Gamification can be defined as:

the concept of applying game mechanics and game design techniques to engage and motivate people to achieve their goals.


The idea is much like the concept behind the Scouts movement – achieve something, earn a badge. Many popular video games also use a badge system, and many of our students enjoy and understand this way of measuring achievement. So it makes sense to use a badges systems in the classroom.

To find out more about using badges in the classroom, have a look at this article:

Automating gamification & badges in education on a (very!) limited budget

Gamification and badges in the learning environment has been of interest to me for sometime. However, within the learning environment I have been working with, the concept would be very labour intensive to implement and track. While playing around with Google Forms, an idea came to me – surely Google Apps script could be used in a self-marking quiz to send a badge to a supplied email address if a certain score was achieved in the quiz?

So I wrote an algorithm and found some potential providers on I contacted them to outline what I wanted. Within hours I had settled with the wonderful Riyafaahf who provided me exactly what I wanted in less than a day.

And below you’ll be able to grab the code and instructions for yourself.

Automating badges in Google Forms

How it works

The student completes a self-marking quiz in Google forms and provides an email address. If the student achieves a certain mark, they will receive a badge via email.

Here is a simple, sample quiz for you to try out and see how it works (don’t worry, I won’t ever use your email address for anything else):

What you will need

  • Access to Google Forms (either through Google Drive or G Suite for Education)
  • Student email addresses (they do not have to be Gmail)
  • An image for your badge (this will be emailed to the student should they achieve a certain score) saved to your Google Drive
  • The code on this page
  • The file ID for your Google Sheet where quiz responses will be collected and the file ID of the badge file  (don’t worry, getting these is easy – see the video if you’re not sure)
  • Devices for students to respond to the form (works well across most platforms including smart phones and tablets)


It might be a good idea to start off with a smaller topic area with a few quizzes (and badges). This allows you to test the waters and the technology. Your badges with be based on the required student outcomes.

It might also be a good idea to think about what you would like students to do with the badges they collect. One simple idea is having each student create a simple eportfolio in Google Slides to save their badges in.

Tips for setting up your quiz in Google Form

Watch video tutorial for visual step-by-step instructions.

You need to save your Google Form as a self-marking quiz and make sure the responses are being collected into a Google Sheet.

  • Make sure you are collecting email addresses. This can be done by asking for an email address in the quiz (use data validation to ensure the address provided appears valid) or selecting the option to collect email addresses in a  G Suite for Education school.
  • Mark all questions as “required”.
  • Select “Make this a quiz” in the form settings.
  • Go through each question and add your points and select the correct answer.

Adding the “Send badge” code

Watch video tutorial for visual step-by-step instructions.

This adds the badge ‘magic’ – sending the badge to the student’s email once they submit their responses.

Below is the code, ready for you to insert your information. You will need to copy it, paste it into your Google Form Script Editor and replace the variable information with your information.

If your browser does not select the code automatically, select all the code from line 1 to line 21 and copy it.

 function onSubmit(e) {
  var sheet = SpreadsheetApp.openById(e.source.getDestinationId()).getSheets()[0];
  //var sheet = SpreadsheetApp.openById("REPLACEwithGoogleSheetsFileID").getSheets()[0];
  var lastRow = sheet.getLastRow();
  var score = sheet.getRange(lastRow, 3).getValue();
  var email = sheet.getRange(lastRow, 2).getValue();
  var subject = "REPLACE with Email Subject";
    var body = "REPLACE with Your Email Message.";
    var id ="REPLACEwithYourBadgeFileID";
    var fileBlob = DriveApp.getFileById(id).getBlob();
    GmailApp.sendEmail(email, subject, body, {
      attachments: [fileBlob]
    var url = ""
    var body = "Good try at the quiz. Have another try to improve your score and earn your solar system expert badge. You can access the quiz at "+ url;
    GmailApp.sendEmail(email, subject, body);


To paste the code into your form:

  • Go to your Google Form
  • Click on the 3 dots at the top right of the screen
  • Select select <> Script Editor…
  • File > New > Project
  • Paste the code
  • Give your project a name
  • Replace variable information as required (see table below)
  • Click on Resources > Current Project’s Triggers
  • Click to add a new trigger. The triggers should look as follows (should be the default):
    Google Apps Script triggers screen shot
  • Review and authorise permissions

You will need to change all or some of the following information for the variables (depending on how your form and spreadsheet are set up). The table below should help you work out what you need to replace.

[table id=3 /]

Test your form

Watch video tutorial for visual step-by-step instructions.

Make sure you test your form before you unleash it on your students. Use the preview button to respond to the form. Check to make sure you get the badge when you answer the right number of questions correctly and you DON’T get the badge when don’t get enough questions right.

Sharing your form

Watch video tutorial for visual step-by-step instructions.

Once you’ve tested your quiz and everything is working okay, you are ready to share! You can email a link or provide a written link. I find the Google Forms URL shortener pretty clunky so I usually use and create a custom, easy to understand URL.

Video tutorial: Automating gamification in education with Google Forms

Other helpful resources

12 free badge images:

Over 120 editable badge images (paid resource):


7 thoughts on “Gamify your classroom with Google Forms

  1. Marilyn Doore says:

    I enjoy your videos and learn a lot. Any suggestions on how to use this when my students don’t have email? Our GAFE domain has that turned off.

    • Tammy says:

      I’d be interested in a response to this question too. I’m just getting ready for my 1st year of using Google Classroom, but I do know that they have all the e-mail addresses blocked or whatever.

    • edavis says:

      That can be tricky, Marilyn. I’ll have a look at how it can be coded so, if they meet the requirements, they are taken to the badge image that they can download rather than having the badge emailed to them.

  2. Steph says:

    I get an error on line 2… on the ID part! Any ideas on how to fix? I’m not that experienced in coding, but I thought I followed all your steps!

    • edavis says:

      Yes, coding can be frustrating! I find the Google apps script can be a bit finicky. I’ve actually had problems with an error at line 2, too. This happened to me when Google updated forms and ‘broke’ my script. Luckily, I was able to fix it fairly simply.

      The other issue might be, if you are a G Suite for Education school, that your administrators might not give users permission to run scripts. There is no way for you or I to be able to tell whether this is the case without asking whoever administers your G Suite for Education system.

      If you think you should have permissions in the system to run scripts, this is how you might fix it:

      First, double check that you have the right file IDs at line 3 and line 10. Instructions are in the video from about 7:10. Note: the ID is only part of the file URL (web address), not the whole lot.

      If that doesn’t work or doesn’t fix the problem, you will need to delete your script project and reenter the code (don’t worry, you’ll just need to copy and paste your code into a new script).

      – from your form, click on the 3 dots (top right) and go to “Script editor….”

      – select all the code for your project, copy and paste it into a blank text document. I like to use Notepad on my Windows computer as a text editor because it doesn’t add any extra formatting like a word processor might do

      – delete the script project in the script project. File > Delete project… Answer any dialogue boxes that pop up.

      – close the script editor then go back into it to create the new project

      – File > New > Project

      – Copy your code from your text document and paste it into the script editor project

      – You’ll need to set up your triggers – instructions are about 12:20 in the video

      – You should be asked to authorise your script – you will be asked by Google to give permission for you script to access parts of your Google account.

      Hopefully, your script should work after that.

      Good luck – let me know how you go.

      Stay Googly!!

  3. I cannot wait to use this! I use Google Slides for interactive notebooks and wanted a way to BADGE my kids after completing the assessment at the end of the unit. This is perfect!

    I’ve just attempted two quizzes. Both have the same issue. No matter what the score on the quiz, the email says “Congratulations”

    Please help!
    Here is line 7-21 – where I think the problem must be.

    var subject = “Thank for completing the Basic Photo Editing Quiz”;
    var body = “Congratulations! You have earned your badge! Remember to copy it to your Padlet!”;
    var id =”0B6H7tjIzY28DalAxOWJURTRuRXM”;
    var fileBlob = DriveApp.getFileById(id).getBlob();
    GmailApp.sendEmail(email, subject, body, {
    attachments: [fileBlob]
    var url = “”
    var body = “Good try at the quiz. Have another try to improve your score and earn your Basic Photo Editing badge. You can access the quiz at “+ url;
    GmailApp.sendEmail(email, subject, body);


Leave a Reply

Your email address will not be published. Required fields are marked *