Skip to main content

Using text variables in Alia

Show live values in your popup text, like consent text, a reward code, a countdown, or a link, without writing code.

Written by Rob D

Text variables show live values in your popup's text, such as your SMS consent text, a reward's code, a countdown, or a link. Alia fills in the value when the popup shows, so each visitor sees their own code or timer.

In the editor, text variables are called expressions. You can add them to text elements, button labels, and a few other fields without writing code.

Insert a text variable

  1. In the popup editor, select a text element or a button.

  2. In the right sidebar, click the Insert an expression icon next to the text field.

  3. In Insert expression, keep Visual selected and click Choose an expression.

  4. Choose what to insert and fill in its details.

  5. Select Done.

The variable appears in the text as a pill. Click the pill to change it in Edit expression. You can't edit a variable by double-clicking the text on the canvas, so use the field in the right sidebar.

What you can insert

Option

What it shows

Countdown

A live timer

Reward

A reward's Code (the code to use at checkout) or Text (its description, such as "10% off")

Link

A link to a page, which can apply a reward's code at checkout

Variables > sms_consent

Compliant SMS consent text

Variables > sms_consent_reply_Y

SMS consent text for reply-Y opt-in

Variables > email_consent

Compliant email consent text

Variables > phone

The last four digits of the visitor's phone number

Variables > question_text

The question's name. Only works inside a survey question

Variables > answer_text

The answer's text. Only works inside a survey answer

Consent text

The consent variables build compliant consent text from your legal name, terms of service URL, and privacy policy URL in Settings. If any of these is missing, Alia blocks publishing and says what to fill in.

The SMS consent text and Email consent text elements already contain these variables.

💡 Note: To translate or reword consent text, replace the variable with your own wording and add your terms and privacy policy links yourself. Make sure the result is still compliant.

Reward codes

To show a discount code, choose Reward, pick the reward, then choose Code or Text.

  • If the visitor has already claimed that reward, they see the code they got.

  • If they haven't, showing the reward claims it for them. For rewards with unique codes, this creates a new code.

To show when the code expires, switch to Code and enter {{ discount_expiration }}.

Countdowns

Choose Countdown, then set:

  • Fixed duration: counts down a set time from when the timer first appears. It starts again if the page is reloaded.

  • To date: counts down to a date and time you pick.

  • To end of: counts down to the end of the current minute, hour, day, week, month, or year, in the visitor's own time.

  • Format: letters (1d 2h 30m) or colons (01:02:30).

  • Units displayed: any of days, hours, minutes, and seconds.

A countdown only shows time. It doesn't close the popup or expire the discount. For a timer on its own line, the Countdown element is easier. See How to insert a countdown timer.

Links

Choose Link and enter the page's URL. You can also:

  • Turn on Apply code at checkout to add a reward's code to the link.

  • Add UTM Source, UTM Medium, and UTM Campaign.

  • Turn on Shorten to use Alia's URL shortener.

Write your own expression

Switch to Code in Insert expression to write any JavaScript expression between double curly braces, such as {{ $alia.user.country }}. See Using JavaScript code expressions in Alia.

💡 Tip: Lia, Alia's built-in AI assistant, can make changes to your popup's text for you from the Lia chat in the popup editor. See Getting started with Lia.

Frequently asked questions

Why does my variable look blank in the editor?

The editor doesn't fill in longer expressions. Use Preview to see what visitors see.

Where did the Discount code option go?

Use Reward > Code instead. It shows the code for the reward you pick.

Why does question_text say "Must be in a question element"?

The text isn't inside a survey question. Move it into the question, or type the question instead.

Can I use a variable in a button label?

Yes. Select the button and use the Insert an expression icon next to its label.

Still have questions?

Start a chat from inside the Alia app, or use the chat in our Help Center.

Did this answer your question?