Variables and Functions in Altcraft
Profile Data
Profile Data
Description | Variable |
---|---|
Email address | {lead.email} |
Phone list | {lead.phones} |
First name | {lead._fname} |
Last name | {lead._lname} |
Birth date | {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} |
Vendor | {lead._vendor} |
Profile ID | {lead._id} |
XXM hash | {lead._xxm} |
XX hash | {lead._xxh} |
MD5 hash | {lead._md5} |
Custom field | {lead.field_name} |
Subscriptions
Profile Subscriptions
Description | Variable |
---|---|
Subscription email address | {subscription.email} |
Email domain | {subscription.email_domain} |
Subscription email list | {subscription.emails} |
Subscription phone | {subscription.phone} |
Subscription phone list | {subscription.phones} |
Push subscriptions list | {subscription.pushes} |
MD5 of email | {subscription.email_md5} |
MD5 of phone | {subscription.phone_md5} |
Subscription hash | {subscription.hash_id} |
Primary subscription field | {subscription_field("channel" "field_name" resource_id)} channel — string like "email" field_name — name of field like "domain" resource — ID like 10 |
The subscription_field
function allows inserting fields from subscriptions regardless of the current message channel. For example:
{subscription_field("sms" "phone")}
If multiple subscriptions match, the one with the highest priority is selected.
Available fields:
Channel | Field | Description |
---|---|---|
Email address | ||
domain | Email domain | |
domain_group | Domain group | |
md5 | MD5 hash | |
sms | phone | Phone |
md5 | MD5 hash | |
push | subscription_id | Push subscription ID |
bundle_id | iOS APNs app bundle ID | |
provider | Push provider |
Similarly, data from custom channel subscriptions can be inserted. Fields in main channels match the SID fields you define when creating the channel.
UTM
UTM Variables
If a profile has UTM tags in their card, they can be inserted into message templates.
Description | Variable |
---|---|
UTM campaign | {lead._utm_campaign} |
UTM source | {lead._utm_source} |
UTM medium | {lead._utm_medium} |
UTM content | {lead._utm_content} |
UTM term | {lead._utm_term} |
External JSON
External JSON Content
External JSON is a way to generate dynamic messages with content from your server at the moment of sending.
Details: Using JSON Content in Messages
Use {json.variable}
in text. list
and object
types support loops. Use {json.object.key_name}
for keys.
Market
Using Market Variables
To include order and product info in messages, insert market variables into the template. More: Using Market Variables in Messages
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 |
Add date | {adddate()} | {adddate(datenow 0 0 3)} → 2018-12-27T18:56:10+0300 |
Full year | {yearlong} | 2018 |
Short year | {year} | 18 |
Month | {month} | 12 |
Day | {day} | 10 |
24-hour | {hours} | 18 |
12-hour | {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: {randomize(lead.Favourite_genres)} → "Detective" |
Array limit | limit | {limit(array[1 2 3] 2)} → [1 2] |
Check if number is even | iseven | {iseven(2)} → true {iseven(3)} → false |
URL encoding | urlencode | {urlencode(lead._regurl)} → http%3A%2F%2Ftest.testdomain.com%2Fsomething |
URL decoding | urldecode | {urldecode(lead._regurl)} → http://test.testdomain.com/something |
Uppercase all letters | uppercase | {uppercase("text")} → TEXT |
Uppercase first letter | uppercasefirst | {uppercasefirst("john")} → John |
Encryption
Encryption and Hashing
Template variable encryption is used when data must be passed via a URL without being exposed in server logs or to the user. For example, you may want to encode pre-filled form data using base58 for decoding on the website side.
Use the crypt
function in the template editor via the </>
button → Encryption:
{crypt(algorithm field key)}
Supported algorithms:
- base58
- base64
- sha1
- sha256
- aes
- blowfish
For sha1, sha256, aes, and blowfish you must provide a key.
AES and Blowfish details:
AES | Blowfish | |
---|---|---|
Initialization vector | First 16 bytes | First 8 bytes |
Mode | CFB | CBC |
Key length | 128-bit (16 chars) | 64-bit (8 chars) |
Padding | zero padding | zero padding |
All encryption/decryption uses Base64URL encoding.
Examples:
{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")}
For string values, wrap in quotes. Numbers can be passed as-is:
{crypt(base58 "value")}
{crypt(base64 42)}
Hash algorithms also support optional salt:
- md5 + salt
- xxh32 + salt
- xxh64 + salt
Same syntax:
{crypt(md5 subscription.email "salt")}
{crypt(xxh32 loyalty.new2.promocode "salt")}
{crypt(xxh64 json.text "salt")}
Encrypted values are Base64-encoded.
Logical Expressions
Logical Expressions
Logical expressions are explained in detail here.
For simple conditions, use the following structure:
{if lead.age gte 18}
18 or older.
{else}
Under 18.
{end}
Fragments
Message Fragments
Fragments are reusable blocks used across multiple messages—such as headers, footers, or social media blocks.
To insert a fragment:
{fragment.<fragment_shortname>}
To insert a random fragment:
{randomfragment[fragment.name1 fragment.name2 fragment.name3]}
More on fragment usage: this article.
Parameters
Parameters
Description | Variable |
---|---|
Sent message ID (SMID) | {send_message_id} |
Resource token | {resource_token} |
Template ID | {msgid} |
Campaign ID | {campid} |
Resource ID | {resid} |
Database ID (profile list) | {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
Service Parameters
Description | Variable |
---|---|
API Content | {apicontent.field_name} |
Cancel message delivery | {cancel} |
Tracking
Tracking Variables
Description | Variable |
---|---|
Tracking domain | {trkdomain} |
Open tracking pixel | {pixel} |
Read tracking pixel | {read} |
Preferences link | {preferences} |
Unsubscribe link | {unsubscribe} |
Global unsubscribe link | {globalunsubscribe} |
Add to suppression list | {suppress} |
Web version link | {webversion} |
Scenarios
Scenario Variables
Description | Variable |
---|---|
Scenario name | {workflow_name} |
Scenario ID | {workflow_id} |
Scenario node ID | {node_id} |
Scenario node type | {node_type} |
Events
Events Variables
Description | Variable |
---|---|
First event | {event.first} |
Last event | {event.last} |
All events | Iterator over the list of events:{for event.all} {.} else - {cancel} if empty array {end} |
Events count | {event.count} |
With these variables, you can pass information about the pixel trigger event in trigger campaings or scenarios. To call it, you need to specify a variable of the type {event.first.<parameter>}
. Optional parameters:
- id
- type
- date
- test
- pixel_id
- goal
- value
- data
- geo_address
- geo_city
- geo_country
- geo_lat
- geo_long
- geo_region
- geo_tld
- geo_time_zone
- geo_zip
- utm_campaign
- utm_content
- utm_keyword
- utm_medium
- utm_source
- utm_term
- user_agent
- accept_language
- vendor
- browser
- os
- origin
- referer
- device
- count_items
- categories
- send_message_id
- channel
- resource_id
- template_id
- campaign_id
- subid
- loyalty_id
- promocode
- content
- custom_data
You can read more about these parameters here.
Emoji
You can insert emoji into your message templates. To do so, select the emoji from the variables menu in the template editor.
Profile Relations
Profile Relations
General syntax:
{relation.[relation_shortname].[direct|reverse].[property].[count|total|top]}
Example: count of direct relations by profit
property:
{relation.managers_loyal.direct.profit.count}
Top reverse relations by profit
, using loop to output:
{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 from direct relations:
{relation.managers_loyal.direct.profit.total}
Editor Functions
Price Formatting
Use this function to separate numbers into groups of three digits with a chosen separator.
Price 8.000 RUR
<p>Price {format json.price "."} RUR</p>
Access it via </>
→ Output Functions → Formatting.
Date Offset
The function adddate(date, year, month, day)
returns a new date with the added interval.
<p>Event starts on {adddate(lead.notify_date 0 0 10)}</p>
It can be used inside format()
:
<p>Event starts on {format adddate(lead.notify_date 0 0 10) "%Y-%m-%D"}</p>
Access via </>
→ Date and Time → Date Offset.
Date Formatting
To format dates based on regional preferences, use this:
<p>Birth date {format lead._bdate "%D.%m.%Y"}</p>
Supported date formatting options:
# 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"
If using external JSON content, Altcraft can parse RFC 3339 strings into datetime:
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 |
Access via </>
→ Date and Time → Formatted Date.