Working with E-mail Templates
Macros
Section titled “Macros”There are various macros presented to you in the e-mail builder tool. These are available for use in any environment (i.e. in Automations and in Social Posts). However, more macros are available for the automations tool. You can find this list below. Some items are marked as objects, which means they provide direct low-level code access to the related object. Our support team can sometimes advise you to use macros based on these objects.
Customer triggers
Section titled “Customer triggers”For all triggers with a customer attached to them, including payment triggers, the following macros are available.
- {{EMAIL}}
- {{FULL_NAME}}
- {{FIRST_NAME}}
- {{LAST_NAME}}
- {{customer}}
- {{code}} (Forgot your password and Email activation request triggers)
Payment triggers
Section titled “Payment triggers”For all triggers with an attached payment, including subcription triggers, the following macros are available:
- {{AMOUNT}}
- {{CURRENCY}}
- {{order_id}}
- {{order}}
- {{cart}} (deprecated)
- {{price_matrix[‘subtotal’]}}
- {{price_matrix[‘shipping’]}}
- {{price_matrix[‘tax’]}}
- {{price_matrix[‘discount’]}}
- {{price_matrix[‘total’]}}
Subscription triggers
Section titled “Subscription triggers”For all triggers with an attached subscription, the following macros are available:
- {{subscription_id}}
- {{subscription}}
Form triggers
Section titled “Form triggers”For all triggers related to Form Submission, the following macros are available:
Form object, with its fields similar to the API:
- {{form}}
- {{form.name}}
Response object, with its fields mapped to the alphanumeric keys in the form structure. An example is below:
- {{form.response}}
- {{form.response.name}}
- {{form.response.email}}
Visibility condition statements
Section titled “Visibility condition statements”While authoring your e-mail, you can also use condition statements to decide whether a container should show for a user or not. The container itself will not be sent in the e-mail’s source.
While inspecting a Container or Columns block in the e-mail builder, navigate to the
Visibility condition field. You can write condition statements using Smarty-style scripting.
To use a macro in the condition statement, you must prefix it with the dollar sign $.
Examples
Section titled “Examples”-
To check whether a customer has an active subscription, you can write the following statement:
$customer.subscriptions|count gt 0 -
To check if the customer is located in the country ZA:
$customer.country_code eq "ZA" -
To check if the customer has a profile picture:
$customer.photo neq ''
For assistance in writing condition statements, contact our support team.
Modifiers
Section titled “Modifiers”Modifiers are Smarty functions that can be applied to macros. They start with a | character. For example, macro|count.
The most common ones you could use are:
- count
- empty
Operators
Section titled “Operators”Use Smarty operators to compare values:
| Operator | Meaning |
|---|---|
eq | Equal to |
neq | Not equal to |
gt | Greater than |
lt | Less than |
gte | Greater than or equal to |
lte | Less than or equal to |
To invert any expression, prefix it with !. For example, !($customer.active) evaluates to true when the customer is not active.
Functions
Section titled “Functions”You can use the below functions to check for conditions inside arrays or to evaluate customer state:
in_array
Section titled “in_array”in_array(16, $customer.tags) evaluates to true if the customer has the tag with ID 16 attached to them.
C:: helper functions
Section titled “C:: helper functions”A set of built-in helper functions is available under the C:: namespace. These simplify common subscription and channel checks.
The group_name argument accepts either a single quoted string or an array of group name strings. When an array is provided, the function matches against any of the listed groups:
- Single group:
'premium' - Multiple groups:
['basic', 'premium']or['insider', 'donation']
The channel_id argument must be a single quoted string. You can prefix any expression with ! to invert it.
| Function | Description |
|---|---|
C::hasActiveSubscription($customer, 'group_name') | True if the customer has an active subscription in the given group. |
C::getActiveSubscriptionPrice($customer, 'group_name') gt 0 | True if the customer’s active subscription price in the given group is greater than 0. Replace gt 0 with any comparison to check a specific price. |
C::neverSubscribed($customer, 'group_name') | True if the customer has never held a subscription in the given group. |
C::hasRetryingSubscription($customer, 'group_name') | True if the customer has a subscription in the given group that is currently in a payment retry cycle. |
C::hasExpiredNotRetryingSubscription($customer, 'group_name') | True if the customer has a subscription in the given group that has expired and is no longer retrying payment. |
C::cardExpiringThisMonth($customer) | True if the customer’s payment card expires in the current month. |
C::subscribedToChannel($customer, 'channel_id') | True if the customer is subscribed to the given channel. |
C::hasTag($customer, 'tag_id') | True if the customer has the given tag assigned to them. |
Examples
-
Show a block only to customers without an active subscription in the “premium” group:
!C::hasActiveSubscription($customer, 'premium') -
Show a block only to customers whose card is expiring this month:
C::cardExpiringThisMonth($customer) -
Show a block only to customers who have never subscribed to the “basic” group:
C::neverSubscribed($customer, 'basic')
Objects
Section titled “Objects”All macros that are objects provide additional properties that can be displayed to the customer or used as conditions.
The object’s structure is the same as the structure you would receive from the API. Below is a list of all properties that you can use.
For arrays, you can apply modifiers. See the modifiers sections.
Customer object
Section titled “Customer object”Identity
Section titled “Identity”| Property | Type | Notes |
|---|---|---|
customer.id | int | Unique customer ID |
customer.loginName | string | Login e-mail address |
customer.displayName | string | Full display name |
customer.photo | string | Profile picture URL; empty string when not set |
customer.accountType | int | 0 = social/passwordless account, 1 = has credentials |
customer.user_type | string | e.g. subscriber |
customer.active | int | 1 when the account is active |
customer.clientId | int | Internal client identifier |
customer.source | string | Acquisition source, e.g. organic |
Location & profile
Section titled “Location & profile”| Property | Type | Notes |
|---|---|---|
customer.country_code | string | ISO 3166-1 alpha-2 country code, e.g. NL |
customer.country | string | Country name |
customer.city | string | City name |
customer.mobile | string | Mobile number in international format |
customer.preferredLanguage | string | BCP 47 language tag, e.g. en |
customer.dateOfBirth | int | Unix timestamp |
customer.lastLogin | int | Unix timestamp of last login |
customer.lastLoginCountry | int | Country ID at last login |
Dates & cohorts
Section titled “Dates & cohorts”| Property | Type | Notes |
|---|---|---|
customer.creationDate | int | Account creation date as Unix timestamp |
customer.creationDay | string | Day and month of creation in DDMM format, e.g. 0101 |
customer.registeredSinceCohort | string | Cohort bucket based on account age: M0, M1-3, M3-6, M6-12, Y1 – Y10+ |
customer.payment_expiry | int | Unix timestamp of the latest payment expiry |
customer.maxExpiry | int | Unix timestamp of the furthest future subscription expiry |
customer.minActivation | int | Unix timestamp of the earliest subscription activation |
customer.totalSubscriptionDays | int | Cumulative active subscription days (rounded up) |
customer.archiveCredits | int | Number of remaining archive credits |
Preferences
Section titled “Preferences”| Property | Type | Notes |
|---|---|---|
customer.preferences | object | Full preferences object |
customer.preferences.optout_marketing | string | "1" if opted out of marketing, "0" otherwise |
customer.preferences.optout_marketing_date | int | Unix timestamp when the opt-out was recorded; 0 if not set |
customer.preferences.country_code | string | Country code stored in preferences |
Address
Section titled “Address”| Property | Type | Notes |
|---|---|---|
customer.address.street | string | Street and house number |
customer.address.city | string | City |
customer.address.postalCode | string | Postal / ZIP code |
customer.address.country | string | ISO country code |
Custom properties
Section titled “Custom properties”| Property | Type | Notes |
|---|---|---|
customer.properties | object | Key-value pairs of custom fields set on the account |
Payment
Section titled “Payment”| Property | Type | Notes |
|---|---|---|
customer.payment | object | Latest payment; may be absent if no payments exist |
customer.payment.id | int | Payment ID |
customer.payment.status | string | e.g. completed |
customer.payment.price | string | Amount as a decimal string |
customer.payment.currency | string | ISO 4217 currency code, e.g. EUR |
customer.payment.price_baseCurrency | string | Amount in the account’s base currency |
customer.payment_tokens | object | Stored payment tokens keyed by provider name (e.g. stripe); only present when a token is on file |
customer.payment_tokens.{provider}.token | string | Provider token |
customer.payment_tokens.{provider}.guid | string | Internal GUID |
customer.payment_tokens.{provider}.expiry | string | Card expiry date |
customer.payment_tokens.{provider}.lastdigits | string | Last 4 digits of the card |
customer.payment_tokens.{provider}.payment_method | string | e.g. card |
Tags & segments
Section titled “Tags & segments”| Property | Type | Notes |
|---|---|---|
customer.tags | int[] | Array of tag IDs assigned to the customer |
customer.tags[n] | int | ID of a single tag |
Subscriptions
Section titled “Subscriptions”| Property | Type | Notes |
|---|---|---|
customer.subscriptions | array | All subscriptions on the account |
customer.subscriptions[n].id | int | Subscription ID |
customer.subscriptions[n].activationDate | int | Unix timestamp |
customer.subscriptions[n].deactivationDate | int | Unix timestamp; 0 if still active |
customer.subscriptions[n].status | int | 1 = active |
customer.subscriptions[n].product | int | Product ID |
customer.subscriptions[n].group | string | Subscription group name |
customer.subscriptions[n].paymentMethod | string | e.g. stripe |
customer.subscriptions[n].nextRenewal | int | Unix timestamp of next renewal |
customer.subscriptions[n].cancellationRequestDate | int | Unix timestamp; 0 if no cancellation requested |
Channels
Section titled “Channels”| Property | Type | Notes |
|---|---|---|
customer.channels | int[] | IDs of channels the customer is subscribed to |
customer.channels_optout | int[] | IDs of channels where the customer has opted out or is inactive |
customer.channels_timestamps_cohort | object | Cohort string keyed by channel ID indicating when the customer subscribed, e.g. { "1": "Y1" } |
customer.channels_details | array | Detailed subscription info per channel |
customer.channels_details[n].channelId | int | Channel ID |
customer.channels_details[n].optout | int | 1 if opted out |
customer.channels_details[n].active | int | 1 if active |
customer.channels_details[n].timestamp | int | Unix timestamp of subscription |
customer.channels_details[n].optout_timestamp | int | Unix timestamp of opt-out; 0 if not opted out |
Engagement
Section titled “Engagement”| Property | Type | Notes |
|---|---|---|
customer.read_posts | int[] | IDs of posts the customer has opened |
customer.click_posts | int[] | IDs of posts the customer has clicked |
customer.read_time | object | Unix timestamp of last open per channel ID, e.g. { "1": 1718700000 } |
customer.click_time | object | Unix timestamp of last click per channel ID |
Order object
Section titled “Order object”- order.id
- order.price
- order.status
- order.responseMessage
- order.lastUpdate
- order.timestamp
- order.userId
- order.paymentMethod
- order.cart (deprecated)
- order.price_matrix
- order.price_matrix.subtotal
- order.price_matrix.tax
- order.price_matrix.discount
- order.price_matrix.shipping
- order.price_matrix.total
- order.items_details (array)
- order.items_details[n].item
- order.items_details[n].price
- order.items_details[n].quantity
- order.items_details[n].item.description
- order.shippingStatus
- order.authorization
- order.address
- order.shipping_address
- order.shipping_price
- order.tax_price
Item object
Section titled “Item object”Inside a Container or Columns block that has a data source set to: Product Items, you can use the below macros:
- item.price
- item.quantity
- item.item.description
Subscription object
Section titled “Subscription object”- subscription.id
- subscription.activationDate
- subscription.deactivationDate
- subscription.status
- subscription.product
- subscription.product.description
- subscription.purchased_item
- subscription.purchased_item.name
- subscription.nextRenewal
- subscription.lastFailedOrder
- subscription.attempts
- subscription.referenceOrderId
- subscription.group
- subscription.group_name
- subscription.paymentMethod