Variables
Variables are custom data fields you can define to store per-subscriber information beyond an email address — things like names, purchase dates, loyalty points, or any other value you want to track and personalize with. Each variable has a tag that becomes a macro you can insert into emails and messages.
Variables are account-wide. Every publication and segment under your account shares the same set of variable definitions.
Variable Types
Each variable has a fixed data type that determines how values are validated and displayed:
| Type | Description | Example Values |
|---|---|---|
| Text | Free-form string | John, Premium, US |
| Number | Numeric value | 42, 9.99, 0 |
| Date | Calendar date | 2026-01-15 |
A variable's type is set at creation and cannot be changed afterward.
Create a Variable
- Navigate to Messaging > Variables.
- Click Create.
- Fill in the fields:
| Field | Required | Description |
|---|---|---|
| Tag | Yes | A unique identifier used in macros. Only lowercase letters, numbers, and underscores are allowed. Displayed with the $esp_ prefix (e.g., entering first_name produces the macro {$esp_first_name}). |
| Type | Yes | The data type: Text, Number, or Date. Cannot be changed after creation. |
| Description | No | An optional note about the variable's purpose. |
| Default Value | No | The fallback value used when a subscriber has no value set. The input adapts to the selected type (text field, number field, or date picker). |
- Click Save.
Edit or Delete a Variable
- To edit, click a variable in the table, update its fields, and click Save. The Type field is read-only after creation.
- To delete, select one or more variables using the checkboxes and click Delete.
Deleting a variable removes it from all subscribers. Any macros referencing the deleted variable will render as empty in future sends.
Using Variables in Emails
Variables can be inserted into email content as macros — placeholders that are replaced with each subscriber's value at send time.
The macro format is:
{$esp_tag}
For example, a variable with the tag first_name produces the macro {$esp_first_name}. When used in an email like:
Hello {$esp_first_name}, thanks for subscribing!
a subscriber with the value Sarah would receive:
Hello Sarah, thanks for subscribing!
If the subscriber has no value set and the variable has a default value, the default is used. If there is no default, the macro renders as empty.
Inserting Macros in the Email Editor
When editing a message in the email editor, click the Macros button to open the macro picker. Select the Variables tab to see a table of all available variables and their macros. Click a variable to insert its macro at the cursor position.
Using Variables in Dynamic Segments
Variables can be used as conditions when building dynamic segments. This lets you create segments based on subscriber data — for example, all subscribers where loyalty_points is greater than 100, or where country equals US.
Available operators for variable conditions:
| Operator | Description |
|---|---|
= | Equals |
!= | Not equal to |
> | Greater than |
>= | Greater than or equal to |
< | Less than |
<= | Less than or equal to |
BETWEEN | Between two values |
NOT BETWEEN | Not between two values |
CONTAINS | Contains the given text |
NOT CONTAINS | Does not contain the given text |
Setting Variable Values
Variable values can be set on individual subscribers in several ways:
- Import — When importing subscribers to a segment, you can map CSV columns to variables during the column-mapping step. Each column can be mapped to a variable or to subscription metadata like email.
- Individual subscription — When creating or editing a subscription for a single subscriber, expand the Variables section to set variable values directly.
- Webhooks — Integrations like ThriveCart and SamCart automatically set variable values from incoming customer data.
- API — Variable values can be set programmatically through the API. See the API documentation for details.
Viewing Subscriber Variables
To view the variable values stored for a specific subscriber, navigate to a subscription record and expand the subscriber details. Variables and their current values are listed alongside the subscription information.
Updated 1 day ago
