Dynamic Tags and Modifiers

You are here:
Estimated reading time: 2 min

Dynamic Tags

Dynamic Tags are pieces of text that are replaced with their corresponding value of what they represent. Use them to personalize your email content, subject line or any other element that support those tags.

For example **|user.firstname|** will be replaced with the user firstname when the email is sent or preview.

Depending on their usage place those can contain information about:

  • campaign: **|campaign.type|** will display campaign type.
    • _id, title, type are available
  • template **|template.title|** will display template title
    • _id, type, title are available
  • user: display user attributes. **|user.country|** will display user country
    • any user attribute
  • user_activity: includes category, product, search query that were processed for the user
    • query > last search
    • item > computed based on interest
    • category > computed based on interest
  • shop: display shop attributes:
    • _id, title, domain, url are available
  • event : display attributes from the event. **|event.query|** will display query value for search event
    • for each event a set of distinct attributes are available
    • event attributes are available for emails triggered by an event: transactional or workflow campaigns only
  • voucher (only available in transactional and workflow campaigns) **|voucher_code|**. View Setup -> Coupon codes
  • timestamp: use to display current date. See date format below
  • date:
    • time returns time in HH:MM:SS format 17:45:56
    • isoformat: returns time in isoformat 2017-02-15T20:26:08.937881-06:00
    • ctime: returns time in ctime format Wed Dec 4 00:00:00 2002
    • date_time: returns time in dd/mm/YY HH:MM format 17/03/22 18:34
    • weekday: returns day of the week (0-6) where 0=Monday, 1=Tuesday
    • now: default is like isoformat but can be used in combination with local_date modifier

Modifiers

Modifiers represent various methods that are applied to the value of those dynamic tags. We support the following modifiers:

  • date: will turn a numeric date into a readable text. It accepts a format parameter and a millisecond
    • date(“%Y-%m-%d”, true) will work with milliseconds values
    • **|timestamp|date(“%Y”)|** will display current Year
    • **|timestamp|date(“%A”)|** will display day of week (english)
  • local_date: works with **|date.now|** to display localized dates:
    • accepts format and locale value
    • local_date(‘EEE’, ‘de’) will display short (max 3 char.) day name in german
    • local_date(‘MMMM’, ‘fr’) will display month name in french
    • read more about possible formats here: https://babel.pocoo.org/en/latest/dates.html
  • truncate(param): truncate the value to maximum length specified in param. Default is 30
  • pretty_price(param): value gets rounded to 2 decimals. If param passed is true then decimals are removed for values that are round. Pass false if you need to display 2 decimals, also .00
    • pretty_price(true)
    • example **|product.price|pretty_price(true)|**
  • md5: convert to md5
  • b64encode: encodes to base64
  • b64decode: decodes from base64
  • urlencode: encodes value as URL
  • default: sets default value if attribute is missing or has an empty value

Default Modifier:

When attribute is missing you can display a default value using this approach default(“dear customer”).

This can be used for any tag. Add |default(‘default_value_here’) after the tag name:

There is a difference between missing attribute and empty value.

Situationdefault(“dear customer”)default(“dear customer”, true)
firstname is missing (not set)dear customerdear customer
firstname exists but it’s empty(empty)dear customer

Examples:

**|product.price|pretty_price|**
**|product.discountPrice|pretty_price(true)|**
**|user.name|default('Dear User')|**
**|user.email|md5|**

Examples for using local_date

Heute is **|date.now|local_date('EEE', 'de')|** und Monatsname ist **|date.now|local_date('MMMM', 'de')|**
Aujourd'hui est **|date.now|local_date('EEE', 'fr')|** et le nom du mois **|date.now|local_date('MMMM', 'fr')|**
Oggi è **| date.now | local_date ('EEE', 'it') |** e il nome del mese **| date.now | local_date ('MMMM', 'it') |**
I dag er **| date.now | local_date ('EEE', 'da') |** og månedens navn **| date.now | local_date ('MMMM', 'da') |**

Considerations

  • Tags and Modifiers are case sensitive: event.Generic.Name will not match the generic field of an event, and neither attribute if it’s sent as name
  • Event.generic.attribute_name are only available for workflow and transactional campaigns
  • Modifiers are only valid within email campaigns and interaction campaigns that are generated on the server side.
  • Not valid tags are removed (replaced with empty string) if there is no data to be replaced with.
Was this article helpful?
Dislike 0
Views: 106