Using Variables in Storyline

Articulate Storyline is a very intuitive e-learning authoring platform that allows for rapid development with almost no skills necessary. Obviously, if you want to stretch the capabilities of the tool and build more complex experiences such as gamified courses or advanced interactions, you will need to understand and master the use of Variables.

Variables in Storyline are used to collect and store information in the form of text, number or true/false statements. The good thing about Storyline Variables is that you don’t need to know anything about coding in order to use them! All you have to do is use a little bit of logic and think how you can leverage variables to get the results you want.

Adding variables in Storyline is very easy and you can follow this tutorial from Articulate to learn the basics. In this particular blog, I’m not going to show how to add variables but, instead, I’m going to give you examples of how you can use them to increase the engagement level of your courses or create more complex interactive elements.

To showcase the many uses of variables, I created a game based on this E-learning Heroes Challenge. The game is simple: you have 20 dollars to spend on groceries. You have to randomly collect items and put them in your cart. Once you proceed to checkout, you will learn if you were able to keep within budget, go overboard or not buy enough items. It’s a guessing game and you will rely on your luck and grocery shopping expertise to ensure you are a savvy shopper.

Let’s take a closer look at how I built this interaction:

1.) I started by building variables for each grocery item to store the true/false value I wanted to carry over to the next slide. Once I had one variable set for each item, I assigned conditions to set the variable to true once the item was dropped on the shopping cart hotspot. By turning these variables on with this specific condition, Storyline will remember only the items that I place in the cart.


Picking Groceries

2.) The next slide will have a checkout counter with all the objects initially in a hidden state. To make just the items you dropped on your shopping cart appear on the checkout counter, I included a trigger for each object to change its state from hidden to normal, on the condition that their variable (remember the variables we were setting on the previous slide?) is equal True.

Screenshot 4

3.) I assigned a price value for each of the items, so you can add them up to your total and compare if you bust your budget or not. For this, I created 2 more variables: totalvalueoforder; itemprice; In addition, each item had also a price variable attached to them, so for instance, for the egg true or false variable,  I also created an egg price number variable and gave it a number.

Screenshot 5

4.) The variable “itemprice” will display the price of each of the items scanned on the Cash Machine by setting variables such as “set itemprice equal to the value of “eggprice” when the user drags shape over hotspot1″

Paying Groceries

5.) The variable “totalnumberofitems” will add the entire purchase and display to the user at the end and let them know if they passed or failed the challenge.


Rock, Paper, Scissors! – Randomizing Content with Javascript

Tool: Adobe Captivate (2017 Release)
Feature: Using Javascript to generate random answers.

This project came as an idea from this E-Learning Heroes Challenge: using Javascript to randomly generate words in Storyline. I decided to take on the challenge and create a game of Rock, Paper, Scissors where the user plays against the computer by thinking of a shape first then challenging the machine with the click of a button. I used Adobe Captivate instead, since I wanted to get more familiar with the use of Javascript with that particular authoring tool.

This solution is very interesting for any type of activity that requires the learner to generate random answers, such as  random words for a writing exercise, or to build flash cards or even to learn a foreign language.


Here’s how I created the Javascript code:

  1. First, I created a variable called “RandomWord” and placed somewhere in the slide using the tags $$RandomWord$$.
  2. Then I create the following Javascript script:

var words = [“Rock”, “Paper”, “Scissors”];
var word = words[Math.floor(Math.random() * words.length)];
window.cpAPIInterface.setVariableValue(“RandomWord”, word);

The first line of the code is where you input the content you want to randomize. Change the third and fourth line to align with the variable name you created  previously (remember, mine is RandomWord)

3. Once you created your variable and your script, create an Advanced Action that to execute the Javascript. In my example, the user clicks the Play button, which in turn initiates the Advanced Action that executes the Javascript.

Click here to see how I created my first Adobe Captivate game using Javascript. I hope this inspired you to find a skill you are trying to stretch a little further and begin conquering it!