Altcraft Variables and Functions
Profile Data
Description | Variable |
---|---|
Email address | {lead.email} |
Phone numbers | {lead.phones} |
First name | {lead._fname} |
Last name | {lead._lname} |
Date of birth | {lead._bdate} |
Gender | {lead._sex} |
Registration date | {lead._regdate} |
Registration IP | {lead._regip} |
Registration city | {lead._regcity} |
Registration country | {lead._regcountry} |
Registration URL | {lead._regurl} |
IP address | {lead._ip} |
City | {lead._city} |
Country | {lead._country} |
Region | {lead._region} |
Postal code | {lead._postal_code} |
Time zone | {lead._tz} |
Provider | {lead._vendor} |
Profile ID | {lead._id} |
XXM hash | {lead._xxm} |
XX hash | {lead._xxh} |
MD5 hash | {lead._md5} |
* Custom field | {lead.custom_field_name} |
Subscriptions
Description | Variable |
---|---|
Subscription email | {subscription.email} |
Email domain | {subscription.email_domain} |
List of subscription emails | {subscription.emails} |
Subscription phone | {subscription.phone} |
List of subscription phones | {subscription.phones} |
List of push subscriptions | {subscription.pushes} |
MD5 hash of email | {subscription.email_md5} |
MD5 hash of phone | {subscription.phone_md5} |
Subscription hash | {subscription.hash_id} |
Subscription field (by channel) | {subscription_field("channel" "field_name" resource_id)} channel — string indicating the channel ("email") field_name — name of the field to insert ("domain") resource — resource ID (e.g., 10) |
The subscription_field
function lets you insert fields from subscriptions regardless of the channel used by the current message. For example, if a profile has an SMS subscription, you can insert their phone number into the email version of the message:
{subscription_field("sms" "phone")}
If several subscriptions match, the one with the highest priority is chosen.
Available fields:
Channel | Field | Description |
---|---|---|
Subscription email address | ||
domain | Email domain of the subscription | |
domain_group | Domain group | |
md5 | MD5 hash of the subscription email | |
sms | phone | Subscription phone number |
md5 | MD5 hash of the subscription phone | |
push | subscription_id | Push subscription ID |
bundle_id | iOS APNs app bundle ID | |
provider | Push provider |
Similarly, you can insert data from custom channel subscriptions into templates. Fields of the main channels correspond to the field SIDs you set when creating the channel.
UTM
If a profile has UTMs in their card, you can insert them into the message template.
Description | Variable |
---|---|
Campaign UTM | {lead._utm_campaign} |
Traffic source UTM | {lead._utm_source} |
Medium UTM | {lead._utm_medium} |
Content UTM | {lead._utm_content} |
Keyword UTM | {lead._utm_term} |
External JSON
External JSON content is a way to create dynamic messages and automate work. It lets you add information generated by your server right at the moment each message is sent.
Read more in “Using JSON content in messages”.
In message text, JSON content appears as variables like {json.variable}
. Data types list
and object
support loops; for object
you can also access elements by key: {json.object.key_name}
.
Market
Using market variables
To use order and product information in mailings, add market variables to your message template. See “Using market variables in messages” for details.
Date and Time
Date and time variables
Description | Variable | Example |
---|---|---|
Formatted date | {format} | {format datenow "%Y-%m-%D %H:%M:%S timezone, %I am"} 2018-12-25 18:56:10 +03:00, 6 pm |
Raw date | {datenow} | 2018-12-25T18:56:10+0300 |
Date offset | {adddate()} | {adddate(datenow 0 0 3)} 2018-12-27T18:56:10+0300 |
Full year | {yearlong} | 2018 |
Year | {year} | 18 |
Month | {month} | 12 |
Day | {day} | 10 |
24-hour format hours | {hours} | 18 |
12-hour format hours | {hours12} | 06 |
AM/PM | {ampm} | PM |
Minutes | {minutes} | 56 |
Seconds | {seconds} | 10 |
Output Functions
Output functions
Description | Variable | Example |
---|---|---|
Number formatting | format | {format 1000000000 ","} 1,000,000,000 |
Variable length | length | {length("abc")} 3 |
Array of values | array | {array[1 "2" 3.3]} [1 2 3.3] |
Random array element | randomize | {randomize(array[1 2 3])} 1 Example: a profile custom field Favourite_genres stores ["Detective", "Humor", "Sci‑Fi"] . {randomize(lead.Favourite_genres)} will output one random element, e.g., "Detective" . Works with Phones, Tags, Array of Objects, as well as arrays in API content and external JSON content. |
Limit array | limit | {limit(array[1 2 3] 2)} [1 2] |
Number is even | iseven | {iseven(2)} => true{iseven(3)} => false |
URL encode | urlencode | {urlencode(lead._regurl)} http:%2F%2Ftest.testdomain.com%2Fsomething Use to encode invalid characters in URL parameters. |
URL decode | urldecode | {urldecode(lead._regurl)} http://test.testdomain.com/something |
Uppercase | uppercase | {uppercase("text")} TEXT |
Uppercase first letter | uppercasefirst | {uppercasefirst("john")} John |
Encryption
Encryption and hashing
Template variable encryption is used when you need to pass data along with a click to a target site but don’t want the data to appear in web server logs or be visible to the user. For example, form prefill data can be encoded in base58 and decoded on the site.
To pass template content and variables in encrypted or hashed form, use the crypt
function. Click the </>
button in the template editor and choose Encryption.
{crypt(algorithm field key)}
You can change encoding or encrypt data with these algorithms:
- base58
- base64
- sha1
- sha256
- aes
- blowfish
For sha1, sha256, aes and Blowfish you must specify a key that will be used on the other side to decrypt the value.
Details for AES and Blowfish:
AES | Blowfish | |
---|---|---|
Initialization vector | First 16 bytes of the string | First 8 bytes of the string |
Cipher mode | CFB (Cipher Feedback) | CBC (Cipher Block Chaining) |
Key length | 128‑bit — 16 chars | 64‑bit — 8 chars |
Padding | zero | zero |
Encryption/decryption uses Base64URL encoding.
Examples of syntax:
{crypt(base58 lead._fname)}
{crypt(base64 lead._lname)}
{crypt(sha256 lead.custom_field "encrypt_key")}
{crypt(sha1 lead._city "encrypt_key")}
{crypt(aes lead._fname "key1234567891234")}
{crypt(blowfish lead._fname "key12345")}
If you need to encrypt a string, wrap it in quotes. For a number, quotes are not needed:
{crypt(base58 "value")}
{crypt(base64 42)}
Hashing algorithms (each supports an optional salt):
- md5 + salt
- xxh32 + salt
- xxh64 + salt
Syntax matches the encryption examples:
{crypt(md5 subscription.email "salt")}
{crypt(xxh32 loyalty.new2.promocode "salt")}
{crypt(xxh64 json.text "salt")}
Note that encrypted data is already Base64‑encoded.
Logical Expressions
Logical expressions
Usage is described in a separate article. For a simple condition:
{if lead.age gte 18}
If 18 or older.
{else}
If younger than 18.
{end}
Parts (Fragments)
Message fragments
Fragments are message blocks reused across messages (e.g., header, footer, social links).
Call a fragment with {fragment.<short_fragment_name>}
.
Call a random fragment from a list: {randomfragment[fragment.name1 fragment.name2 fragment.name3]}
.
See more in this article.
Parameters
Description | Variable |
---|---|
Sent message ID (SMID) | {send_message_id} |
Resource token | {resource_token} |
Template ID | {msgid} |
Campaign ID | {campid} |
Resource ID | {resid} |
Database (profiles) ID | {listid} |
Campaign SUBID | {subid} |
Resource name | {resname} |
Database name | {listname} |
Message type | {msg_type} |
Resource URL | {resurl} |
Resource domain | {resdomain} |
Message name | {msgname} |
Campaign name | {campname} |
SMS sender name | {from_name_sms} |
Segment ID | {segid} |
Segment name | {segname} |
Attribute value | {attribute_value("attribute")} where "attribute" is the API name of the attribute |
Service
Description | Variable |
---|---|
API content | {apicontent.field_name} |
Cancel message sending | {cancel} |
Tracking
Description | Variable |
---|---|
Tracking domain | {trkdomain} |
Pixel recording an open | {pixel} |
Pixel recording a read | {read} |
Subscription manager link | {preferences} |
Unsubscribe link | {unsubscribe} |
Global unsubscribe link | {globalunsubscribe} |
Add to suppression list | {suppress} |
Web version link | {webversion} |
Workflow
Description | Variable |
---|---|
Workflow name | {workflow_name} |
Workflow ID | {workflow_id} |
Node (element) ID | {node_id} |
Node (element) type | {node_type} |
Events
Event variables let you work with user actions (page views, add‑to‑cart, purchases, etc.) collected via pixels and goals.
How it works
- Real data is populated only when a trigger actually fires or within a running workflow.
- Events are context‑bound — in triggers they are events of that trigger; in workflows they are events since entry.
These variables are only available for trigger-based campaigns and scenarios that use the "Pixel activation" method.
Variables
Description | Variable | Notes |
---|---|---|
First event | {event.first} | The oldest event in the current context |
Last event | {event.last} | The most recent event in the current context |
All events | {event.all} | Full list of events in reverse arrival order; index [0] is the last |
Event count | {event.count} | Number of events in the queue |
Using in templates
To get a specific event field, append the parameter with a dot:
{event.first.goal} // goal of the first event
{event.last.value} // value of the last event
{event.first.geo_city} // city from the first event
{event.last.utm_source} // source from the last event
{event.first.browser} // browser from the first event
{event.first.categories} // categories from the first event
To iterate over all events, use a loop:
{for event.all}
{.}
{else}
No events to display
{end}
Examples
Trigger message after add‑to‑cart:
You left an item: {event.first.data.product}
Price: {event.first.data.price}
Buy: {event.first.data.link}
Segmentation by geolocation:
A sale is happening in your city {event.first.geo_city}!
Source: {event.first.utm_source}
Campaign performance analysis:
Source: {event.last.utm_source}
Campaign: {event.last.utm_campaign}
Browser: {event.last.browser}
Event fields in detail
Basic fields
Field | Type | Description | Example |
---|---|---|---|
id | string | Unique event ID | {event.first.id} |
type | string | Platform event type | {event.last.type} |
date | DateTime | Event date and time | {event.first.date} |
test | bool | Test event flag | {event.last.test} |
Geo data
Field | Type | Description | Example |
---|---|---|---|
geo_country | string | Country (full name) | {event.first.geo_country} |
geo_tld | string | Two‑letter country code | {event.first.geo_tld} |
geo_region | string | Region | {event.first.geo_region} |
geo_city | string | City | {event.first.geo_city} |
geo_address | string | Address | {event.first.geo_address} |
geo_zip | string | Postal code | {event.first.geo_zip} |
geo_time_zone | string | Time zone | {event.first.geo_time_zone} |
geo_lat | float | Latitude | {event.first.geo_lat} |
geo_lon | float | Longitude | {event.first.geo_lon} |
UTM tags
Field | Type | Description | Example |
---|---|---|---|
utm_source | string | Traffic source | {event.first.utm_source} |
utm_medium | string | Traffic medium | {event.first.utm_medium} |
utm_campaign | string | Campaign name | {event.first.utm_campaign} |
utm_content | string | Content identifier | {event.first.utm_content} |
utm_term | string | Keyword | {event.first.utm_term} |
utm_keyword | string | Alternative keyword | {event.first.utm_keyword} |
Pixel event (Pixel: goal
)
Field | Type | Description | Example |
---|---|---|---|
pixel_id | int | Pixel ID | {event.first.pixel_id} |
goal | string | Goal name | {event.first.goal} |
value | float | Goal value | {event.first.value} |
data | object | Custom goal data | {event.first.data.order_id} |
browser | string | User’s browser | {event.first.browser} |
user_agent | string | Browser User‑Agent | {event.first.user_agent} |
accept_language | string | Browser language | {event.first.accept_language} |
count_items | int | Number of items | {event.first.count_items} |
categories | string[] | Array of categories | {event.first.categories} |
send_message_id | string | Message send ID | {event.first.send_message_id} |
API call event (API: api_call
)
Field | Type | Description | Example |
---|---|---|---|
content | object | Data from API call | {event.first.content.order_id} |
custom_data | object | Custom API data | {event.first.custom_data.field_name} |
Event types
Group | Type | Description |
---|---|---|
Pixel | goal | Pixel/goal activation (including via API) |
API | api_call | API call through a workflow or trigger start |
Note: All fields of different event types are available at the same level. For example, {event.last.content}
refers to the content
field of an API call event if that is the current event.
See the developer documentation for full technical details and limits. This helps you set up API data collection precisely and use it correctly in templates.
Emoji
You can also insert emoji into your message templates. Choose the emoji picker in the variables menu and click the emoji you want.
Profile Relations
General variable formula:
{relation.[relation_short_name].[direct for direct or reverse for reverse].[property_name].[count — count, total — sum, top — top relations]}
Count of direct relations with profit
property:
{relation.managers_loyal.direct.profit.count}
Top reverse relations by profit
. A loop is used to output multiple values:
{for $index $item = relation.managers_loyal.reverse.profit.top}
{$item.lead._fname} {$item.lead._lname} ({$item.value} profit)
{else} There is no ‘profit’ for you :(
{end}
Sum of profit
across direct relations:
{relation.managers_loyal.direct.profit.total}
Additional Editor Functions
Price formatting
A number formatting function splits numbers into groups of three with a given delimiter.
Price 8.000 RUR
<p>Price {format json.price "."} RUR</p>
To insert, click </>
in the editor and choose Output functions → Formatting.
Date offset
The adddate(date, year, month, day)
function returns a date after adding the specified interval.
<p>Event starts on {adddate(lead.notify_date 0 0 10)}</p>
adddate()
can be used inside format()
:
<p>Event starts on {format adddate(lead.notify_date 0 0 10) "%Y-%m-%D"}</p>
To insert, click </>
→ Date & time → Date offset.
Date formatting
Date values differ by locale. Use date formatting for subscriber‑friendly dates.
For example, to show the subscriber’s date of birth as:
Date of birth 02.11.1998
Use:
<p>Date of birth {format lead._bdate "%D.%m.%Y"}</p>
All date formatting parameters:
# years
"%y": "06"
"%Y": "2006"
"yy": "06"
"YYYY": "2006"
# months
"%m": "01"
"MM": "01"
"%B": "January"
"month": "January"
"%ru_month": "январь"
# days
"%d": "2"
"%D": "02"
"DD": "_2"
"%A": "Monday"
"weekday": "Monday"
# hours
"%H": "15"
"%I": "3"
"hh": "15"
"hours": "15"
"twelve_h": "3"
# mins
"%M": "04"
"mm": "04"
# seconds
"%S": "05"
"ss": "05"
# am/pm indicator
"am": "pm"
"AM": "PM"
"%p": "pm"
# timezone
"tzone": "-07"
"timezone": "-07:00"
"%Z": "Z0700"
To insert, click </>
→ Date & time → Formatted date.
If the template uses content from external JSON (apicontent
variable or dynamic JSON content), the platform can convert RFC 3339 strings into date/time.
Formatting example:
Mode | Format |
---|---|
JSON | "date_time": "2023-02-21T11:10:35.141Z" |
Template | {format apicontent.date_time "%Y-%m-%d %H:%M:%S"} |
Preview | 2023-02-21 11:10:35 |