Overview
Dynamic subject lines can be generated at message send time and rendered uniquely for each contact based on contact attribute values such as subscription plan tiers. This example will take advantage of Smarty to include custom Sculpt template variables into the message subject line. The Smarty logic for matching the correct subject line values with chosen contact attribute values will be stored as HTML Content in Cordial. See the result of our example.
Choose a Contact Attribute
Start by choosing an existing contact attribute or adding a new one. In this example, we are using an existing custom contact attribute called Tier, which accepts subscription plan tier names of Silver, Gold, Platinum, and Default.
Note the Attribute Key as it will be referenced in our Smarty logic to check contact's subscription plan tier.

Create the Sculpt Template
Navigate to Content > Sculpt Templates and create a new template. You can also edit an existing Sculpt template by simply adding a new section and form fields as described below. For detailed instructions on how to create and edit Sculpt templates, please visit the Sculpt Templates overview article.
We are naming our sculpt template Dynamic Subject Lines and adding four text fields to the template section titled Subjects.
Enter a different plan tier name in each Field Label along with the corresponding subject line as the text field Default Value. The default value entries will eventually be displayed as subject lines of your messages.

Sculpt template variable key names will be generated automatically as you fill out the required information. Click the Data Output icon above the section title to view the generated JSON data. We are going to reference these key names in our Smarty logic within the HTML content.

Create the HTML Content Include
Navigate to Content > HTML Content and create a new HTML include entry. Provide the name, unique key, and optionally, a description.
Paste the Smarty logic provided below and customize all instances of the $contact.tier
variable to match your custom contact Attribute Key and expected values. Also, customize all instances of $templateSettings.subjects.variable_key_name
to use your Sculpt template variable key names.
This Smarty logic will check the contact's tier value, and based on that value, output one of four possible subject lines stored in the Sculpt template we created earlier.
{if $contact.tier|lower == 'platinum'} {$data.subject = $templateSettings.subjects.platinum} {else if $contact.tier|lower == 'gold'} {$data.subject = $templateSettings.subjects.gold} {else if $contact.tier|lower == 'silver'} {$data.subject = $templateSettings.subjects.silver} {else} {$data.subject = $templateSettings.subjects.default} {/if}
Take note of the HTML content Key as it will be used to reference this content in the subject line of a new message.

Create a New Message
We now have all of the prerequisites to dynamically generate message subject lines.
Start by creating a new message (batch or automated) and select Sculpt as the message editor.
From the message properties page, locate the Message Header section and click Edit.
Paste the following Smarty code into the Subject field:
{include 'content:dynamic_subject' scope='parent' assign='blackhole'}{$data.subject}
- content:dynamic_subject - includes our HTML content using the content Key.
- scope:parent - places our HTML content at the top of the hierarchy, making it available to subsequent variables and functions.
- assign:blackhole - assigns HTML content to this variable, which is never referenced anywhere else.
- $data.subject - displays the message subject line.

Lastly, search for your Sculpt template by name in the Message Content section. Click on the template name to begin composing your message.

You can change your subject lines at any time by editing the Sculpt template text field Default Values. No other fields need to be edited unless you are making changes to variable names.
This is the expected result of our example. Dynamically generated subject lines based on contacts' subscription plan tier. Message content in this example is the same for all recipients but should be personalized as well.

Comments
0 comments
Please sign in to leave a comment.