In this video
- Declare a variable in the Variables manager: a name, a type (Number, Text or Boolean) and a starting value
- Change it from any trigger with Set Variable: set, add, subtract, multiply, divide or random
- Show the live value in any text with Insert Variable — {stamps} / 5 stamps
- Reveal an object with Show If Variable, checked live the moment the value changes
- Stop a counter with "Only run if a variable matches"
- Test it with Play, then remix the finished coffee loyalty template
- Three mistakes to avoid: hiding with the eye, unnamed variables, conditions that can never come true
About this video
Variables are what let a playable ad remember what the player did — a score, a choice, a stamp count — and react to it. In the Playable Ads Maker a variable is declared once for the whole project, so every scene can read it, the End Card included, and it starts fresh every time the ad is played. Set Variable changes it from any tap, hold or timer; any text can print it with Insert Variable; Show If Variable reveals an object when it reaches a value; and any action can be limited with an "only run if" condition. This video builds a coffee stamp card in a blank project, which works on every plan, and then shows the finished coffee loyalty template you can remix. Next in the series: every Text setting.
Exports for Unity, AppLovin, Google, IronSource, Mintegral, Meta (Facebook), Moloco, TikTok, Liftoff, Vungle, Chartboost, InMobi and Pangle — one self-contained HTML5 file each.
Transcript
Captions in 18 languages on YouTube
Tap the cup, and the card counts every stamp. At five, a free coffee unlocks.
That's a variable at work. In the next few minutes, you'll build this card from scratch, without code.
A variable is a named value your ad remembers while it plays: a number, a piece of text, or true or false.
Read the full transcriptShow less
Use one whenever the ad should react to what the player already did: a score, a choice, a reward they've earned.
Variables belong to the whole project, so every scene can read them, the End Card included. They start fresh every time the ad is played.
Start a blank project in the Playable Ads Maker. Anything you build from scratch, variables included, works on every plan.
Variables live in the toolbar. Click Variables, then Add variable.
Name it stamps. That name is how you'll show the value later, so use letters, numbers and underscores.
Keep the type as Number, and the starting value at 0. Text holds words, like a name the player picked. Boolean is a simple yes or no.
Now something to tap. I'll add an image and upload a coffee cup.
With the cup selected, open Events and add a Tap.
Add an action and choose Set Variable. Pick stamps, choose Add, and type 1.
A number can be set, added to, subtracted, multiplied, divided, or rolled at random. Text can be set or appended, and a Boolean can be set or toggled.
Compute and Look Up write to variables too, and a progress bar can follow one. Each gets its own video later in this series.
To show the count, add a text, and make its box wider before you type.
Click Insert Variable and pick stamps. It drops the name in, wrapped in curly brackets.
Type the rest of the line. The canvas already shows the live value: 0 of 5.
Now the reward: one more text. Free coffee unlocked.
Under Show If Variable, pick stamps, choose ≥ (greater than or equal to), and type 5.
Press Escape to deselect it, and it's gone. Stamps is 0, so it stays hidden until the card is full. It's checked live, the moment the value changes.
Last, stop the count at 5. On the cup's action, click Only run if a variable matches, and set stamps < 5.
All of this works the same in portrait and landscape, and in every language: a translated text keeps its curly-bracket name, and the value fills in.
Time to test it. Press Play, and tap the cup.
Every tap adds one, and the text keeps up. At five, the reward appears.
Tap again, and nothing changes. The condition holds it at 5.
Three mistakes to avoid. First, don't hide the reward with the eye in the layers list.
An object hidden there doesn't exist while the ad plays, so no action can ever show it. Start it visible, and gate it with Show If.
Second, give every variable a name. An unnamed one never appears in any list, so nothing can use it.
And third, make sure a condition can come true. Stamps stops at 5, so a rule waiting for more than 5 never runs.
Want the finished version? The coffee loyalty template does all of this and more: a double-tap bonus, a happy hour, and a reward on its End Card. Remix it, and make it yours.
Next up: text, and every setting it has. See you in the next video!