Dynamic variables let you show visitor specific text inside your onsite experiences. You can use them in any campaign or widget to inject any form of data that you collect about your visitors.
Available variables
Some form fields automatically create variables for you. These variable names are fixed and cannot be changed.
You use these variables directly in your content.
Form field | Variable | Example output |
| ||
Basic phone number |
| +46701234567 |
International phone number |
| +46701234567 |
First name |
| Alex |
Last name |
| Smith |
Full name (first + last name) |
| Alex Smith |
Using fallbacks
Fallbacks control what happens when a value is missing. They decide whether the text stays readable or breaks.
Fallback vs no fallback
This shows the same message and the output, with and without fallback for an example visitor that is identified, but with an empty first name property.
Visitor | Message | Result |
|
Without first name | Hello {{firstname}}! | Hello ! | β |
Without first name | Hello {{firstname | "friend"}}! | Hello friend! | β |
As you can see in the first row, since the firstname-property is empty in the customer profile, you will create a small empty "space".
Fallback format
Use this format:
{{key | "fallback"}}
When to use a fallback
Use a fallback when the value might be missing.
Common cases:
New visitors
Visitors who skip a field
Visitors without a complete customer profile
Good examples:
Hello {{firstname | "there"}},Hello {{firstname | "friend"}}We will contact you at {{email | "your email"}}You selected {{plan | "a plan"}}Your rating is {{csat1 | "registered"}}
Using Custom Variables
The default variables use a (hidden) key, which is the identifier for the field. The email field uses a key called "email" and so on. In all other fields, the key of the field becomes the variable name.
Examples of fields that use keys:
Singleline field
Multiline field
Dropdown
Radio buttons
Button choices
Checkbox list
NPS
Date field
Every component that can ask the user to select or write something has its own key that can be used to repeat the value of the input, in a success step or when they return to your website at a later date.
You set the key in the editor. Then you use the same text inside {{ }}.
Example:
If the key is nps1, the variable is {{nps1}}.
Important note: Password fields cannot be used as dynamic variables.
Step by step
Step 1. Open your campaign
Go to Campaigns and open the campaign you want to edit.
Step 2. Add or select a component
If you need new data, add a form field.
If you use a fixed field, you will not see a key setting.
If you use a key based field, set the key.
Step 3. Find the component key
Click on the field you want to use. Look for the Key setting.
[Screenshot: Field settings with the Key highlighted]
Step 4. Insert the variable in your content
Click the text element you want to personalize.
Type the variable where it should appear.
Examples:
Hi {{firstname || "there"}}Your score was {{nps1 || "not answered"}}
Step 5. Preview and test
Preview the campaign.
Test both cases:
A visitor who has submitted the field
A visitor who has not submitted the field
Step 6. Publish
Save your changes and publish the campaign.
Troubleshooting
The variable shows as plain text
Check the braces. It must be {{ and }}.
The variable is blank
Add a fallback.
Example:
{{nps1 || "not answered"}}
The wrong value shows
Check the key.
It must match exactly.
Keys are case sensitive.
I cannot find the key setting
You are likely using a fixed field. Use the fixed variable name instead.
Example:
Use {{email}} for the Email field.
I want to use profile fields
Profile fields are not supported for variables in onsite content. Use fixed variables or field keys instead.