Custom Tags
Tags are engaging personalization features that can be applied to all Message types. In addition to all of your Player Properties, Teak provides other builtin tags for data from Facebook, email, local notifications, and rewards.
You can see all of the available tags by selecting the @
icon when creating Messages.
Facebook Tags
If your game has integrated the Facebook SDK, and provides Teak with Facebook App Scoped User IDs through IdentifyUser then you can use these builtin Facebook tags to personalize message content with the player’s real name.
{{first_name}}
-
Insert the player’s first name
{{last_name}}
-
Insert the player’s last name
{{full_name}}
-
Inser the player’s full name
Teak will replace these tags with an empty string for any players who have not connected with Facebook. We highly recommend using these tags with the default
filter to provide a fallback name for players who are not Facebook connected.
Email Tags
Teak provides a set of email specific tags for use in email message content.
{{email.link}}
-
Insert Teak’s generated tracking/reward URL for the email. Note that in Teak’s provided email template, the image already links to the generated tracking/reward URL for the email.
{{email.unsubscribe}}
-
Insert the URL to the player’s subscription management page for email. Note that in Teak’s provided email template, the unsubscirbe link is already included in the email footer.
{{email.footer}}
-
Insert the default email footer into the email. Note that the footer is already included in Teak’s provided email template.
{{email.send_id}}
-
Insert Teak’s unique id for the specific email send. This may be useful to correlate clicks on other links with events reported to your internal analytics tooling through Teak’s Data Syncing.
{{email.to_address}}
-
Insert the email address the email is being sent to.
If you are inserting any tags into a link in an email, be sure to use the url_encode
filter to properly escape the text so the link will function correctly.
Local Notification Tags
When a Message is associated with a Local Schedule you can use custom tags from data passed in by the game as personalizationData
when it makes the Teak SDK call to send the notification (See Teak.Notification.Schedule
). All of the data passed in as personalizationData
will be available under local
.
Ask your dev team what data they are passing in as personalizationData
. In particular, you will need to know the name of the "keys" that the dev team is using, since you will need to know the name of the "key" to template data into the message. For example, if the call provides data in a key named level
, you can template the data into the Message with the tag {{local['level']}}
.
We highly recommend using a default filter on all tags using local
to provide a fallback in case the personalizationData
in the Teak SDK call does not include the appropriate key. Ask your dev team if this can happen, and consider what would be appropriate to show to the player if the relevant data is not provided.
Reward Tags
When a Message has an attached Reward Bundle Teak provides a set of tags to template the amount of each item or currency that the player will receve into the notification. The format of these tags is reward['<internal id of item or currency>'].amount
. For example if your game has a currency with an internal id of coins
, reward['coins'].amount
. We recommend using the @
icon to insert these tags.
When the Reward Bundle is randomized, instead of a single amount tag Teak provides minimum and maximum amount tags. These tags can be used to inform players of the maximum reward they could receive — "Tap now to win up to X FREE COINS" or their guaranteed win — "Everyone’s a winner, tap now to win at least X FREE COINS". The format of thse tags is reward['<internal id of item or currency>'].min
or reward['<internal id of item or currency>'].max
. We recommend using the @
icon to insert these tags.
When the Reward Bundle is tiered any reward tags will automatically use the values for the tier the player is in when the notification or email is sent.
Providing a Fallback
Sometimes a tag might not be available for a player. For example, not all players will be Facebook connected, so the {{first_name}}
tag will not always have content. You can provide fallback content using the default filter.
For example, {{first_name|default: "Hey Pal"}}
will template Hey Pal
into the notification if the player is not Facebook connected.
The default filter can be used with any tag. Because it is so important, you can directly insert it into your message content from the @
icon menu by clicking the {{x|y}}
button by any tag.
Other customizable Tags
- Simplify a large complex number
-
{{some_number | number_to_human}}
If there is a player property calledsome_number
, thenumber_to_human
filter will simplify that value to something you would say in conversation.
If a player has a total of 300,144 Coins, your message could say "Let’s make you a millionaire! Collect 700,000 Coins to add to your balance of 3 Hundred Thousand."
If you’d rather have more numeric places, you can add a qualifier. For instance {{coins| number_to_human: 3}}
would display their balance as 300 Thousand
.
If you prefer the complex number: {{some_number}}
will do the trick in the above example it would output 300,144
. And if you want to get rid of the comma, use {{some_number | unfancy}}
to display 300144
.
Standard Filters
Filters modify the result of an output statement. Teak supports the following Liquid Filters:
append
-
append a string e.g.
{{ 'foo' | append:'bar' }} #=> 'foobar'
capitalize
-
capitalize words in the input sentence
ceil
-
rounds a number up to the nearest integer, e.g.
{{ 4.6 | ceil }} #=> 5
date
-
reformat a date (syntax reference)
default
-
returns the given variable unless it is null or the empty string, when it will return the given value, e.g.
{{ undefined_variable | default: "Default value" }} #=> "Default value"
divided_by
-
integer division e.g.
{{ 10 | divided_by:3 }} #=> 3
downcase
-
convert an input string to lowercase
escape_once
-
returns an escaped version of html without affecting existing escaped entities
escape
-
html escape a string
floor
-
rounds a number down to the nearest integer, e.g.
{{ 4.6 | floor }} #=> 4
lstrip
-
strips all whitespace from the beginning of a string
minus
-
subtraction e.g.
{{ 4 | minus:2 }} #=> 2
modulo
-
remainder, e.g.
{{ 3 | modulo:2 }} #=> 1
newline_to_br
-
replace each newline (\n) with html break
plus
-
addition e.g.
{{ '1' | plus:'1' }} #=> 2
,{{ 1 | plus:1 }} #=> 2
prepend
-
prepend a string e.g.
{{ 'bar' | prepend:'foo' }} #=> 'foobar'
remove_first
-
remove the first occurrence e.g.
{{ 'barbar' | remove_first:'bar' }} #=> 'bar'
remove
-
remove each occurrence e.g.
{{ 'foobarfoobar' | remove:'foo' }} #=> 'barbar'
replace_first
-
replace the first occurrence e.g.
{{ 'barbar' | replace_first:'bar','foo' }} #=> 'foobar'
replace
-
replace each occurrence e.g.
{{ 'foofoo' | replace:'foo','bar' }} #=> 'barbar'
round
-
rounds input to the nearest integer or specified number of decimals e.g.
{{ 4.5612 | round: 2 }} #=> 4.56
rstrip
-
strips all whitespace from the end of a string
size
-
return the size of an array or string
slice
-
slice a string. Takes an offset and length, e.g.
{{ "hello" | slice: -3, 3 }} #=> llo
split
-
split a string on a matching pattern e.g.
{{ "a~b" | split:"~" }} #=> ['a','b']
strip_html
-
strip html from string
strip_newlines
-
strip all newlines (\n) from string
strip
-
strips all whitespace from both ends of the string
times
-
multiplication e.g
{{ 5 | times:4 }} #=> 20
truncate
-
truncate a string down to x characters. It also accepts a second parameter that will append to the string e.g.
{{ 'foobarfoobar' | truncate: 5, '.' }} #=> 'foob.'
truncatewords
-
truncate a string down to x words
upcase
-
convert an input string to uppercase
url_encode
-
url encode a string