How can we help?

Dynamic subject lines using Sculpt

Overview

Dynamic subject lines can be generated at the time you send a message and rendered uniquely for each contact based on contact attribute values, such as subscription plan tiers.

The following 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.

Choose a Contact Attribute

1. In Cordial, navigate to Data > Contact Attributes and choose an existing contact attribute or add a new one. In this example, we'll use an existing custom contact attribute called Tier, which accepts subscription plan tier names of Silver, Gold, Platinum, and Default.

Note: After creating a new contact attribute, existing contact profiles will need to be updated with appropriate values for that attribute.

2. Take note of the Attribute key because it will be referenced in our Smarty logic to check contacts' subscription plan tier.

Create the Sculpt Template

1. 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. In this example, our Sculpt template is named Dynamic Subject Lines.

2. At the top right corner of your template, click the Settings Form Builder icon  to add sections.

3. Click the + icon in the What fields will your form settings have? pane to add a section.

4. Click Add Field and enter a plan tier name in each Field Label, along with the corresponding subject line in the Default Value text field. The default value entries will eventually be displayed as subject lines of your messages.

Note: Sculpt template variable key names will be generated automatically as you fill out the required information.

5. Click the Save Template button in the upper right.

6. Back in your template, click the Data Output icon above the section title to view the generated JSON data.

Create the HTML Content

1. Navigate to Content > HTML Content and create a new HTML entry. Provide the name, unique key, and, optionally, a description.

2. 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}

3. Take note of the HTML content Key as it will be used to reference this content in the subject line of a new message.

4. We now have all of the prerequisites to dynamically generate message subject lines.

Create a new message

1. Navigate to Messages > Create New Message and select Sculpt as the message editor.

2. From the message properties page, locate the Message Header section and click Edit.

3. Paste the following Smarty code into the Subject field:

{strip}{include 'content:dynamic_subject' scope='parent' assign='blackhole'}{$data.subject}{/strip}
Note: Sculpt template variables can be used in all message header fields (Subject, From Email, Reply Email, and From Description).
  • 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.

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

Note: Selecting a Sculpt template other than the one containing your subject lines and Sculpt template variable key names will not result in dynamic subject lines being generated.

5. 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.

Expected result

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.