Skip to main content
Documentation for version v73

Altcraft Variables and Functions

Profile Data

DescriptionVariable
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

DescriptionVariable
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:

ChannelFieldDescription
emailemailSubscription email address
domainEmail domain of the subscription
domain_groupDomain group
md5MD5 hash of the subscription email
smsphoneSubscription phone number
md5MD5 hash of the subscription phone
pushsubscription_idPush subscription ID
bundle_idiOS APNs app bundle ID
providerPush provider
tip

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.

DescriptionVariable
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

DescriptionVariableExample
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

DescriptionVariableExample
Number formattingformat{format 1000000000 ","}

1,000,000,000
Variable lengthlength{length("abc")}

3
Array of valuesarray{array[1 "2" 3.3]}

[1 2 3.3]
Random array elementrandomize{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 arraylimit{limit(array[1 2 3] 2)}

[1 2]
Number is eveniseven{iseven(2)} => true

{iseven(3)} => false
URL encodeurlencode{urlencode(lead._regurl)}

http:%2F%2Ftest.testdomain.com%2Fsomething

Use to encode invalid characters in URL parameters.
URL decodeurldecode{urldecode(lead._regurl)}

http://test.testdomain.com/something
Uppercaseuppercase{uppercase("text")}

TEXT
Uppercase first letteruppercasefirst{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:

AESBlowfish
Initialization vectorFirst 16 bytes of the stringFirst 8 bytes of the string
Cipher modeCFB (Cipher Feedback)CBC (Cipher Block Chaining)
Key length128‑bit — 16 chars64‑bit — 8 chars
Paddingzerozero
tip

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

DescriptionVariable
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

DescriptionVariable
API content{apicontent.field_name}
Cancel message sending{cancel}

Tracking

DescriptionVariable
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

DescriptionVariable
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.
info

These variables are only available for trigger-based campaigns and scenarios that use the "Pixel activation" method.

Variables

DescriptionVariableNotes
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

FieldTypeDescriptionExample
idstringUnique event ID{event.first.id}
typestringPlatform event type{event.last.type}
dateDateTimeEvent date and time{event.first.date}
testboolTest event flag{event.last.test}

Geo data

FieldTypeDescriptionExample
geo_countrystringCountry (full name){event.first.geo_country}
geo_tldstringTwo‑letter country code{event.first.geo_tld}
geo_regionstringRegion{event.first.geo_region}
geo_citystringCity{event.first.geo_city}
geo_addressstringAddress{event.first.geo_address}
geo_zipstringPostal code{event.first.geo_zip}
geo_time_zonestringTime zone{event.first.geo_time_zone}
geo_latfloatLatitude{event.first.geo_lat}
geo_lonfloatLongitude{event.first.geo_lon}

UTM tags

FieldTypeDescriptionExample
utm_sourcestringTraffic source{event.first.utm_source}
utm_mediumstringTraffic medium{event.first.utm_medium}
utm_campaignstringCampaign name{event.first.utm_campaign}
utm_contentstringContent identifier{event.first.utm_content}
utm_termstringKeyword{event.first.utm_term}
utm_keywordstringAlternative keyword{event.first.utm_keyword}

Pixel event (Pixel: goal)

FieldTypeDescriptionExample
pixel_idintPixel ID{event.first.pixel_id}
goalstringGoal name{event.first.goal}
valuefloatGoal value{event.first.value}
dataobjectCustom goal data{event.first.data.order_id}
browserstringUser’s browser{event.first.browser}
user_agentstringBrowser User‑Agent{event.first.user_agent}
accept_languagestringBrowser language{event.first.accept_language}
count_itemsintNumber of items{event.first.count_items}
categoriesstring[]Array of categories{event.first.categories}
send_message_idstringMessage send ID{event.first.send_message_id}

API call event (API: api_call)

FieldTypeDescriptionExample
contentobjectData from API call{event.first.content.order_id}
custom_dataobjectCustom API data{event.first.custom_data.field_name}

Event types

GroupTypeDescription
PixelgoalPixel/goal activation (including via API)
APIapi_callAPI 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.

info

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:

ModeFormat
JSON"date_time": "2023-02-21T11:10:35.141Z"
Template{format apicontent.date_time "%Y-%m-%d %H:%M:%S"}
Preview2023-02-21 11:10:35