See also: Merge tags in Ometria
Merge tags with timestamps
These merge tags allow you to update templates and fields with dynamic timestamps either based on your contact's timezone or your account timezone.
Timestamps
All of the tags below that give the current date and time render in an ISO format by default.
This is so we can process their result correctly in other filters, giving you more flexibility.
When using these dates and times to display to your customers, we recommend using a date/time formatter like 'date', 'datetime' and 'strftime'.
Visual editor
Contact's timezone isn't available in the Ometria visual editor, so for previews you'll see the browser timezone instead. You can still convert the timezone using the 'tz' filter.
'Datetime' and 'date' locale sensitive formatters render in ISO format in the visual editor, but will display correctly in preview sends and real sends.
Note: All hash functions return a dummy value in the visual editor.
Displays the current datetime in the
contact's timezone.
If there's no known timezone for that contact, the account timezone is used as a fallback.
E.g. “2023-04-05 02:02:03+01:00"
Displays the current datetime in your
account’s timezone.
If the account’s timezone is “Europe/London”, and UTC time is 2023-04-05 01:02:03+00:00:
E.g. “2023-04-05 02:02:03+01:00"
The tz filter allows you to set the timezone on the datetime.
If the profile’s timezone is “Europe/London”, and UTC time is 2023-04-05 01:02:03+00:00:
“2023-04-05 2023-04-05 01:02:03+00:00"
{{ now | tz('America/Los_Angeles')}}
Same as above, with any timezone.
E.g. “2023-04-05 04:23:42-07:00"
Displays the current date in the profile’s timezone, falling back to the account’s timezone.
E.g. If the profile’s timezone is “Europe/London”, and UTC time is 2023-04-05 23:59:03+00:00: “2023-04-06" (note that since this is British Summer Time, it is already the next day for this profile):
Displays the current date in UTC.
E.g. If UTC time is 2023-04-05 23:59:03+00:00: “2023-04-05"
Displays the current date in the account’s timezone.
E.g. If the account’s timezone is “Europe/London”, and UTC time is 2023-04-05 23:59:03+00:00: “2023-04-06” (since this is British Summer Time, it's already the next day for this account).
{{ now | strftime('%Y-%m-%d__h%Hm%M') }}
The strftime filter allows custom formatting of datetimes.
E.g. “2023-04-05__h12m23”
Merge tags with calculation filters
These merge tags allow you to perform calculations and create filters from dates and numbers.
{{ now | datetime('full') }}
The datetime, date, time filters use the account’s locale to print the 'full' date format.
E.g. If the account locale is "en_UK.UTF8" (or “en_UK”): "Wednesday, 7 June 2017 at 14:00:00 British Summer Time"
{{ now | datetime('long') }}
The datetime, date, time filters use the account’s locale to display a 'long' date format.
E.g. If the account locale is "en_UK.UTF8" (or “en_UK”): "7 June 2017 at 14:00:00 BST"
{{ now | datetime('medium') }}
The datetime, date, time filters use the account’s locale to display a 'medium' date format.
E.g. If the account locale is "en_UK.UTF8" (or “en_UK”): "7 Jun 2017, 14:00:00"
{{ now | datetime('short') }}
The datetime, date, time filters use the account’s locale to display a 'short' date format.
E.g. If the account locale is "en_UK.UTF8" (or “en_UK”): "07/06/2017, 14:00"
{{ today | date('medium') }}
Locale-based formatting on a date.
E.g. If the account locale is "en_UK.UTF8": "6 Apr 2023"
{{ now | add({'hours': 2}) }} and {{ now | subtract({'days': 2}) }}
Add or subtract an amount of time from a date or datetime.
Note: This must be done before formatting your date, for example with the datetime/date/time filters or strftime.)
E.g. If the profile’s timezone is “Europe/London”, and UTC time is 2023-04-05 01:02:03+00:00, then:
- {{ now | add({‘hours’: 2}) }} results in “2023-04-05 04:02:03+01:00"
- {{ now | subtract({‘days’: 2}) }} results in “2023-04-03 01:02:03+01:00"
{{ profile.properties.[date field] | add({'days': 365}) }}
Any date field.
E.g., if the profile has a custom date field ‘last_purchase_date’ containing the date “2023-01-01”: “anniversary of last purchase is at 2024-01-01"
{{ today | subtract( profile.properties.last_purchase_date) | datepart('days') }}
Subtract two dates.
If today is 2023-04-05 and the profile has a custom date field ‘last_purchase_date’ containing the date “2023-01-01”:
Note: You can subtract two dates or two datetimes, but not a combination of dates and datetimes.
E.g. "it has been {{(today |subtract( profile.properties.last_purchase_date) | datepart(‘days’) }} days since your purchase" renders as: "it has been 4 days since your purchase"
Note: The add, subtract and datepart filters accept the following time units (both plural and singular): years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds.
Calculate the sum of a value from two numbers.
E.g. "{{ 5 + 4 }}" renders as "9"
Multiplying a string field with a number results in repeating the string.
E.g. "{{ '3'* 4 }}" renders as "3333".
To avoid this, use casting (adding int or float, as shown below).
Note: If you multiply a string, Ometria may show NaN (not a number) in the app, though it will display correctly in the email.
Convert a value to get an integer (whole number).
E.g. "{{ '3.2'|int }}" renders as "3"
This tag makes sure that any number stored in a text (string) field is first converted to a whole number (integer).
This is to avoid unexpected side effects like multiplying a text field with a number, which could result in repeating the text instead of a calculation.
Here's the correct way to use a number stored in a text field and multiply it by a number:
E.g. "{{ '3.2'|int * 4 }}" renders as "12"
As above, this tag makes sure that a decimal number (float) stored in a text (string) field will be correctly multiplied by a number, by converting the text field to a decimal.
E.g. "{{ '3.2'|int * 4 }}" renders as "12.8"
Displays the number as an absolute value, e.g. changing a negative number into a positive number. E.g. "{{ -3.2|abs}}" renders as "3.2"
The following hash functions are available as filters.
- sha1
- sha256
- sha384
- sha512
- md5
E.g. "077454edf4bf8bd07430de53cc2dea185dde1e09"
Comments
0 comments
Article is closed for comments.