Macros

Macro Basics

Macros allow you to personalize elements of a notification for each subscriber that receives it.

Using the Macro List

The list of available macros can be shown by clicking the {} icon inside of the title, body, or landing URL text box. Once the list is open, click on any of the macros to automatically insert it.

If you are sending subscriber properties via our SDK or a custom integration the macro list will also show these as options under the Custom grouping.

Specifying a Default Value

It is always good practice to specify a default replacement value when using a macro. This ensures that even if the subscriber does not have a value for the chosen macro the text displayed will make sense.

To specify a default value add the following after the name of the macro:

{{profile.city | default: "your area"}}

Examples

If you are sending a notification focused on a weather event and want to target a geographic area that includes multiple cities but want to ensure that the subscriber's city is displayed in the notification's title you could accomplish this with the following:

Tornado Warning in {{profile.city | default: "your area"}}. Take Cover!

In the above example, if the subscriber who is receiving the notification has a city in their profile the title will be displayed as: Tornado Warning in Miami. Find Shelter!. If they do not have a city then the title will read Tornado Warning in your area. Find Shelter!.

Remember to use our Preview Functionality to ensure your macros look the way you expect!

Advanced Usage

Our macro functionality supports the use of Liquid Templates to add more customization to the substituted value. We support both the control flow and iteration tags as well as the use of most filters.

If you would like help constructing macros for your notification please reach out to your account manager.

Filter: Date Format

You can use the date filter to convert a date to any format you desire. For example, to provide the date the subscriber opted in to notifications as part of your landing page URL:

https://ex.com/?subscribed={{profile.subscribed_date | date: '%Y-%m-%d'}}

The following date format strings are supported:

Input

Format

%a

The abbreviated weekday name (E.g., Sun)

%A

The full weekday name (E.g., Sunday)

%b

The abbreviated month name (E.g., Jan)

%B

The full month name (E.g., January)

%d

Day of the month (01..31)

%e

Day of the month (1..31)

%H

Hour of the day, 24-hour clock (00..23)

%I

Hour of the day, 12-hour clock (01..12)

%k

Hour of the day, 24-hour clock (0..23)

%l

Hour of the day, 12-hour clock (0..12)

%m

Month of the year (01..12)

%M

Minute of the hour (00..59)

%p

Meridian indicator (E.g., AM or PM)

%S

Second of the minute (00..60)

%Y

Year with century

%%

Literal % character

Filter: Relative Dates

The relative_date filter allows you to provide a date in a wide range of grammatical date formats and have it converted to an absolute date.

For example, if you need to include last Saturday's date in the URL of your notification and format it as Year/Month/Day you can provide the following macro:

https://ex.com/{{'the saturday before today' | relative_date | date: '%Y/%m/%d'}}/example

Note the inclusion of the date filter to format the date as desired. If not provided, the relative_date filter will return an ISO-8601 formatted date (E.g.,2020-09-10T15:41:41).

Some additional examples of the type of relative dates formats you can use:

next thursday
last wednesday
today
tomorrow
yesterday
next week
next month
next year
3 days from now
three weeks ago

Additionally, you can prefix any of the above with the following to further alter the computed date:

day after
the day before
the monday after
the monday before
2 fridays before
4 tuesdays after

Since there is an ambiguity in the grammar of relative date formats always use the Notification Preview functionality to ensure the relative date is properly interpreted.

Last updated