Content Tokens

Content Tokens allow a marketer to personalize messages. For example, an admin can put a token firstname into an email to display the member’s first name.

Content Tokens also allow a marketer to define simple, reusable bits of content, such as the “from” email address when sending mailings. Tokens support localization, so these bits of content can vary based on the member’s language preference.

Content Tokens can usually just be called “Tokens.” One could also think of them as “Dynamic Content Tokens,” since they are dynamic.

Using Tokens

All tokens can be used in the content editor, either formatted as Token Elements or Merge Tokens. Tokens of type “merge” can contain the Merge Token syntax. The predefined system tokens are used implicitly in special places in the system, such as the Email From address.

The content editor will show a real-time preview of Test Members for all Token Elements.

Token Elements

Tokens can be inserted into content as Token Elements. These are valid DOM elements (such as a DIV, SPAN, or IMG tag) with a CSS class in the format “stl_token_”.

Examples:

Apply To…

Each token has an Apply To setting that defines how the value of a token will be applied to the Token Element.

Since the token variable will be used as part of a CSS class name, it is critical that the token variable be validated as a valid CSS class name when defined by the admin.

If the member attribute value is empty or null, then the token “Default Value” should be used instead, even if the default value is blank.

Token Types

The Loyalty Content Token supports six types:

Merge Tokens

Merge Tokens can contain references to other Content Tokens, including conditional logic. The token value is built up as a merged string of several other tokens that are expanded inline in the outer string of the token definition, such as “Name: {{stl_token_firstname}} {{stl_token_lastname}}”.

Merge Token syntax surrounds each tokens variable in double curly braces, such as “{{stl_token_firstname}}”.

Basic Usage

Enclose variables in double curly braces {{ }}, e.g. “Dear {{ stl_token_first_name }},”

Do not surround your merge token with quotes “ “ or those will appear in the output.

Merge Tokens cannot contain other Merge Tokens, to prevent recursion.

Like all tokens, you can localize the format for various customer locales.

Advanced Usage: Handlebars

Merge Tokens use Handlebars syntax, which has conditional logic and can accommodate even complicated needs. For basic syntax, refer to: http://handlebarsjs.com/expressions.html. See below for various loyalty examples, some of which are quite advanced.

A handlebars expression is a {{, some contents, followed by a }}. These can include other Content Tokens or conditional logic.

Merge Tokens support two custom Handlebars operators, “iff” and “if_eq”. Both are case-sensitive. Both allow a and b as tokens or literal values. The supported operators for “iff” are ===, >, or <.

The tilde (“~”) character in the examples below is Handlebars “whitespace control”.

Example: Cascading Defaults

This example shows how to test multiple attribute values, using the first that is not empty.

{{#if stl_token_card_id}}{{stl_token_card_id}}

{{~else}}{{stl_token_loyalty_card_id}}{{/if}}

{{#if stl_token_card_id}}{{stl_card_id}}

{{~else if stl_token_card_id}}{{stl_card_id}}

{{~else}}#

{{~/if}}

Salutations

Salutations can be constructed as Merge Tokens. Even formal salutations with nuanced and complicated social rules are possible.

Example: USA Salutation

Dear {{stl_token_first_name}},

Example: Italian Salutation

{{#if stl_token_lastname~}}

    {{~#if_eq stl_token_gender 'f'~}}

        cara {{stl_token_lastname}}

     {{~else~}}

        caro {{stl_token_lastname}}

   {{~/if_eq}}

{{~else~}}

  caro

{{~/if}}

Example: German Salutation

{{#if stl_token_lastname~}}

    {{~#if_eq stl_token_gender 'm'~}}

        Sehr geehrter Herr {{stl_token_academicdegree}} {{stl_token_lastname}}

     {{~else if_eq stl_token_gender 'f'~}}

        Sehr geehrte Frau {{stl_token_academicdegree}} {{stl_token_lastname}}

     {{~else~}}

        Sehr geehrte(r) Herr/ Frau {{stl_token_academicdegree}} {{stl_token_lastname}}

   {{~/if_eq}}

{{~else~}}

  Sehr geehrte Damen und Herren

{{~/if}}

Example of Setting up a Content Token

The instructions for setting up the First Name content token are below:

  1. Go to Admin > Content > Content Tokens.

  2. Type “First Name” and select token type “Member Attribute”, then click “Create”.

  3. Choose the Member Attribute “First Name”.

  4. Set a Default Value like “Friend” in case any members do not have a first name set.

  5. Leave API Visible=checked (true) so your web and mobile clients can use this token.

  6. Click on “Save” and the dialog will close; your content token is now available for use.

Sample Content Tokens

The tokens listed below are commonly used by other programs. For your convenience, Loyalty automatically creates the tokens marked with an asterisk (*) but you can customize them as needed.

Token Name

Type

Setup

First Name *

Member Attribute

Member Attribute = First Name; Default Value = “Friend”

Last Name

Member Attribute

Member Attribute = First Name; Default Value = “”

Member ID *

Member Attribute

Member Attribute = Member ID

Email *

Member Attribute

Member Attribute = Email

Point Balance *

Metric

Metric = Point; Metric Value = Balance; Default Value = “0”

Full Name

Merge Token

Value = “ ”

Salutation

Merge Token

Value = “Dear , ”

Program Name

Static

Value = “Loyalty Program”

Support Email

Static

Value = “support@example.com”

Support Phone

Static

Value = “(650) 555-1212”

Program Home

Static

Value = “https://example.com”, Apply To = “Link”

Message Template Content Tokens

Loyalty has some content tokens with special behavior in Message Templates. These are not editable and do not appear in the list of content tokens.

Token Variable

Apply To

Behavior

stl_operational_hidden

element

Hides element if message setting Operational=true

stl_web_version

link

links to the “web version” of the email message

stl_unsubscribe

link

links to Communication Preferences content page.