Skip to main content
Altcraft Docs LogoAltcraft Docs Logo
User guide iconUser guide
Developer guide iconDeveloper guide
Admin guide iconAdmin guide
English
  • Русский
  • English
Login
    User documentation
    Getting Started
    FAQ
    Altcraft glossary
      Profiles and databasesarrow
    • Subscription resources
      Managing databases
      Subscriber profile
      Profiles import and data update
      Scheduled customer data import
      Automatic data collection
      Bulk customers profiles update
      Double opt-in subscription
      Suppression lists
      Profile relations
      Profile history export
      Profile export
      Creating a static segment based on import results
      How to open a CSV file
      Matching
      Types of fields in the database
      Global control groups
      Subscription Manager
      Communication channelsarrow
      • Email channelarrow
      • Email: ISP interactions best practices
        Email: sending domain configuration
        Email: setting up and using postmasters
        Быстрый старт
        Push channelarrow
        • Mobile Pusharrow
        • Settings & implementation
            Integrate your app with Altcraftarrow
          • Providers: push message structure
            Processing and adding a subscription
            Event registration
          Web pusharrow
        • Preliminary Settings
            Web browser push configurationarrow
          • Firebase Cloud messaging
            Apple Safari
            Mozilla Services
          Connecting Web Push to a Website
          Transferring Data to the Platform
          Web Push SDK Methods
            Import of subscriptions from third-party push servicesarrow
          • Migrating push subscriptions from third-party services
            How to transfer push subscriptions configured for Safari?
            Migration from OneSignal
      SMS channel
        Creating mailing from scratcharrow
      • Email
        SMS
        Web Push
        Mobile Push
        WhatsApp
        Viber*™
        Руководство: SMS-рассылка через VK Notify
        MAX Bot
        MAX Group
        Notify
        Telegram Bot
        Telegram Group
      Communication Channels Workflow
      Руководство: SMS-рассылка через УТШ
      Руководство: push-рассылка через сервис от "Согласие"
      Segmentationarrow
    • Static Segments
      Dynamic Segments
      Updatable Segments
        Segmentation Conditionsarrow
      • Segmentation by Profile data
        Segmentation by Interactions with Entities
        Segmentation by Activity of the channel
        Segmentation by external data
        Segmentation by external SQL tables
        Segmentation by Profile structure
      Best Send Time (BST)
      Logical operators "AND" and "OR"
      Recommendations for working with segments
      Message templatesarrow
      • Working with message templatesarrow
      • Working in the editor
        Email-template
        SMS template
        Push template
        MAX template
        Telegram template
        WhatsApp template
        Viber™ template
        Notify template
        Visual editor for email-templatearrow
      • Visual editor interface
        Adding blocks
        Elements and their settings
        Custom blocks
        Style manager
        Layer manager
      Template fragments
      Image gallery
      Content personalization
      Creating tables based on array elements
      Block editor for email template
        Altcraft Variables and Functionsarrow
      • Logical expressions in messages
        Loops in messages
        Market variables in templates
        Using the JSONPath functionality
        Dynamic content in messagesarrow
      • Dynamic HTML content
        Dynamic JSON content
        Content from SQL database in templates
        Dynamic API content
      Importing and exporting a message template
      Importing a template from a third-party service
      Exporting a template from Pixcraft
      Mailingsarrow
    • Mailings calendar
      Broadcast mailings
      Regular mailing
      Trigger mailing
      Multivariate testing
      Mailing testing
      Mailing schedule
      Placement mailing
      Campaignsarrow
    • Working with Campaigns
      Local control groups (LCG)
      Audience expansion
      Audience building
      Automation scenariosarrow
    • Managing scenarios
      Nodes of the scenario
      Classic marketing scenarios
      Step-by-step welcome scenario guide
      Scenario for automatic notification of the manager
      Abandoned cart scenario
      Marketarrow
    • Market settings
        Productsarrow
      • How to create a product manually
        How to import a product from a file
        Scheduled product import
        Product and SKU Segments
        Preparing the YML file
      Orders
      Market variables in message template
      Guide: how to send an order confirmation email
      Loyalty programsarrow
    • Loyalty programs
      Loyalty integration with external systems
      Быстрый старт
      Basic loyalty program use cases
      Order Segments
      Promotion codes
      Reports and analyticsarrow
    • Channel report
      Traffic report
        Summary reportarrow
      • Summary report metrics
      Cohorts report
      Lifetime report
      Funnels report
      Goals report
      Audience growth report
      Click map report
      Loyalty programs report
      Bounces report
      Undeliveries report
      Report on global control groups
      Integrationsarrow
      • Action hooksarrow
      • Altcraft Action Hooks
        Action hooks event types
        Action Hook Message Structure
        JSON batch request (HTTP POST action hook)
        Message to RabbitMQ broker
        Message to RabbitMQ exchanger
        Message to Kafka broker
        Test event
        Integration of third-party services using Albatoarrow
      • Connecting Altcraft to Albato
        Launching the welcome scenario using Albato
        Transmitting event data
        Setting app a trigger mailing
        Event registration
        Google Sheets and Altcraft integration
        AmoCRM and Altcraft integration
      Facebook Ads Manager™
      Google Ads Audiences
      MAX
      Yandex.Audience™
      VK Ads™
      Static segment synchronization
      Yandex AppMetrica™
      Tilda™
      Lpgenerator™
      WhatsApp
      Viber*™ integration
      Integration scope
      Data Transmitted During Synchronization
      Notify
      Weblayersarrow
      • Formsarrow
      • Create a form
        Form constructor
        Appearance
        Actions after form activation
        Data analytics
        Binding data channel and forms
        Conditional logic in forms and surveys
        NPS testing
        Pixelsarrow
      • Goal customer actions and scoring
        Pop-upsarrow
      • Creating and publishing a pop-up
        Setting up a popup in the code editor
        Managing pop-ups manually via script
        Popup analytics
        Guide: pop-up for push subscriptions
        Case: Creating a pop-up with the "Wheel of Fortune" widget
        Basic cases of placing a popup via the Tag Manager
        Tag Managerarrow
      • Configuring and installing Tag Manager
        Trigger types
        Variables types
        Linking a pixel and the Tag manager
      Settingsarrow
    • Account settings
      Custom links
      Virtual senders
      Sending policies
      Audit journal
      Tags FAQ
        Users, groups and accessarrow
      • Two-Factor Authentication (2FA)
        Connectionsarrow
      • Connection to Facebook Ads Manager
        Connection to Google Ads
        Connecting to Yandex.Audience™
        Connection to 360dialog
        Connection to Edna
        Connection to Devino Telecom
        Connection to SMSTraffic
        Connection to VK Ads™
        Connection to MTS OmniChannel
        Custom Authentication Connection
        OAuth2 connection
        Basic Authentication connection
        Token Authentication connection
        Connection to Rapporto
        MAX connection
        Connection to Notify
      Attribute settings
      API requests: where to startarrow
    • Import or update a profile
      Trigger mailing launch
      Engage profile in scenario
      Changelogarrow
    • v2026.1.76
      v2025.4.75
      v2025.4.74
      v2025.3.73
      v2025.2.72
      v2025.1.71
      v2024.4.70
      v2024.3.69
      v2024.2.68.2
      v2024.1.68
    Documentation archive
    library
  • Message templates
  • Altcraft Variables and Functions

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​

Subscription variables contain data related to a specific subscription and the delivery channel being used. For example, it is not possible to pass a phone number when sending via email using these variables.

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" 1)}

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
telegram_bot/telegram_groupidChat ID
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
Mailing 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}

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.

Fragments and Parts

The platform also includes similar functionality called parts. Parts differ from fragments in that they are configured and used within a single email. To start working with parts, add the variable {part.example_part} to the template code. After that, the Content tab will appear at the bottom of the page, where you can configure the template parts.

Read more about parts here.

Parameters​

DescriptionVariable
Sent message ID (SMID){send_message_id}
Resource token{resource_token}
Template ID{msgid}
Mailing ID{campid}
Resource ID{resid}
Database (profiles) ID{listid}
Mailing SUBID{subid}
Resource name{resname}
Database name{listname}
Message type{msg_type}
Resource URL{resurl}
Resource domain{resdomain}
Message name{msgname}
Mailing 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 mailings 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 $index $event = event.all}
{if $event.goal equal "cart"}
{formatdate $event.date "%Y-%m-%D to %H:%M"} added to the cart {$event.data.count}x {$event.data.product}.
{end}
{else}
<p>No events...</p>
{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}

Mailing performance analysis:

Source: {event.last.utm_source}
Mailing: {event.last.utm_campaign}
Browser: {event.last.browser}

For use in scenarios with the Event Waiting node:

Hello, {user.name}!

You recently added a new item to your cart but didn’t complete the purchase.

Your item is waiting for you:
{event.last.product_name}

Event fields​

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_campaignstringMailing 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.

Loyalty programs​

When inserting loyalty program variables via the insert dialog in the editor, a context menu opens where you can select a loyalty program and a points type (as well as the transaction count limit and transaction activation period for the last two variables):

DescriptionVariable
Member points balance{loyalty_program.<LOYALTY_PROGRAM_ID>.points.<POINTS_ID>.balance}
Member active points balance{loyalty_program.<LOYALTY_PROGRAM_ID>.points.<POINTS_ID>.active_balance}
Member inactive points balance{loyalty_program.<LOYALTY_PROGRAM_ID>.points.<POINTS_ID>.inactive_balance}
Balance with currency name{loyalty_program.<LOYALTY_PROGRAM_ID>.points.<POINTS_ID>.balance_named}
Active balance with currency name{loyalty_program.<LOYALTY_PROGRAM_ID>.points.<POINTS_ID>.active_balance_named}
Inactive balance with currency name{loyalty_program.<LOYALTY_PROGRAM_ID>.points.<POINTS_ID>.inactive_balance_named}
List of ближайших expirations (where x is the transaction count limit and y is the transaction activation period){loyalty_expiration_points(<LOYALTY_PROGRAM_ID> "<POINTS_ID>" x y "desc")}
List of nearest points activations (where x is the transaction count limit and y is the transaction activation period){loyalty_activation_points(<LOYALTY_PROGRAM_ID> "<POINTS_ID>" x y "acs")}

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.

You can format and shift the date at the same time using the following function:

{format adddate(datenow 0 0 3) "%Y-%m-%D"}

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>

You can format and shift the date at the same time using the following function:

{format adddate(datenow 0 0 3) "%Y-%m-%D"}

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
Last updated on Oct 10, 2025
Previous
Block editor for email template
Next
Logical expressions in messages
  • Profile Data
  • Subscriptions
  • UTM
  • External JSON
  • Market
  • Date and Time
  • Output Functions
  • Encryption
  • Logical Expressions
  • Fragments
  • Parameters
  • Service
  • Tracking
  • Workflow
  • Events
    • How it works
    • Variables
    • Using in templates
    • Examples
    • Event fields
      • Basic fields
      • Geo data
      • UTM tags
      • Pixel event (Pixel: goal)
      • API call event (API: api_call)
      • Event types
  • Loyalty programs
  • Emoji
  • Profile Relations
  • Additional Editor Functions
    • Price formatting
    • Date offset
    • Date formatting
© 2015 - 2026 Altcraft, LLC. All rights reserved.