CakeMail: Home | Français | Blog

Getting started with CakeMail

Set up your account in a few simple steps.

Read the guide

Intro to Dynamic Content

Getting Started With Dynamic Content

First things first: In order to make good use of the dynamic content feature, you’ll need to be comfortable with HTML, working in ‘source code’ mode in the HTML editor, and writing a little code along the way.

Escape From HTML

All Dynamic Content is inserted into emails by adding code in [square brackets] . Your dynamic content can be formatted with HTML, but all of the instructions for Dynamic Content must be contained within square brackets like these in order to work properly: [ ] This quick sample will give you an idea:

<p>This is going to stay here just like it’s written.
<b> [Dynamic Content Goes Here] </b> 
<br/> This is going to stay here just like it’s written, too.

A basic dynamic content expression is generally set up as follows:

[IF variable operator constant]
<HTML code to display result>
[ELSEIF variable operator constant]
<HTML code to display alternative result>
[ELSE]
<HTML code to display when no result matches>
[ENDIF]

This quick documentation will outline the rules for variables, operators, constants, and expressions, which will help you get started writing your own.

Type of Data Supported

Dynamic content supports a number of different data types, meaning that there are a few ways in which you can create expressions for variables that decide which content gets displayed.

Supported data types are:

  1. boolean - TRUE or FALSE
  2. integer - Any whole number ranging from -8388608 to 8388608
  3. string - An alphanumeric string up to a maximum of 255 characters
  4. date - Date with the format “YYYY-MM-DD HH-MM-SS”

Hours must be written in 24-hour clock (so 18:30 instead of 6:30 PM)

Variables

Variables are the criteria that you’re basing your content on. This can include list fields like firstname, lastname, or any other data field your subscribers have submitted content to. It can also include campaign activity, allowing you to send specific content to just those who clicked on a link or opened a previous email campaign.

List Fields

List fields can be used as criteria. The value of these fields generally changes with every list subscriber. The variables are enclosed by the apostrophe character ( ` )

List fields can be any of the integer, string or date/time data types.

Previous Campaign Activity

We can also refer to action a subscriber has taken for a previous email campaign including opening the message, or clicking on any links in the email itself. To refer to a specific campaign, you’ll need to find the mailing ID and refer to it using MAILING(id), where id is a reference to the campaign number. To refer to a specific link, you’ll need to find the link ID and refer to it using LINK(id), where id is a reference to the link number.

Example: MAILING(43243) LINK(3245364)

An email campaign has two different statuses: CLICKED and OPENED A link can be: CLICKED

How to find an Email Campaign ID in your branded site

  1. Select the Campaigns tab.
  2. Find the specific campaign you wish to refer to.
  3. View stats for this campaign.
  4. The Mailing ID will be included in the URL that displays in the address bar of your browser. Use only the 6 or 7-digit number that appears at the end of the URL: http://mail.youraccountname.com/ui/mailings/stats/560416

How to find a Link ID in your branded site

  1. Select the Campaigns tab.
  2. Find the specific campaign you wish to refer to.
  3. View stats for this campaign.
  4. Access the clicks report for the campaign.
  5. View the detailed stats for the link you wish to use as your variable. The Link ID will be included in the URL that displays in the address bar of your browser. Use only the 7 or 8-digit number that appears after the text “link=”: http://mail.youraccount.com/ui/mailings/stats/560416?page=logs&link=7224929

Operators

The following operators are supported: For list fields that are text strings

  • LIKE - Matches
  • NOT LIKE - Does not match

For list fields that are integers or datetime

  • = - Equal to
  • ! = - Not equal to
  • < - Less than
  • < = - Less than or equal to
  • > - Greater than
  • > = - Greater than or equal to

For campaign activity (links or mailings)

  • IS
  • IS NOT

For expressions

  • AND
  • OR

Constants

Contants must be enclosed in double quotes ‘ “ ‘ if they are of text strings, datetime or integer data types.

Examples:

  1. "NY"
  2. "2010-08-02 10:00:00"
  3. "5"

Expressions

Dynamic content supports boolean expressions (TRUE / FALSE). Expressions can be created by combining a variable, an operator and a constant.

Example:

`email` LIKE “%hotmail%”

(their email address contains the text “hotmail”)

Example:

`id` > “1000”  

(list ID is greater than 1000)

Example:

MAILING(34342) IS OPENED

(subscriber opened campaign #34342)

The variable and the constant must be the same data type.

Expression can be combined together to become a larger and more complex expressions by using parentheses.

Example:

(`email` LIKE “%hotmail%”) AND (MAILING(34342) IS OPENED)

(their email address contains the text “hotmail” AND they opened campaign #34342)

Control Structures

A control structure gives the starting statement for the expression, and can be nested for more complex expressions.

IF

[IF expression]
 HTML code to display

Displays HTML code if expression is TRUE

ELSEIF

[ELSEIF expression]
 HTML code to display

Follows an [IF] statement. Displays HTML code indicated if the previous [IF] expression is FALSE but the expression from [ELSEIF] is TRUE. There can be multiple [ELSESIF] statements.

ELSE

[ELSE]
 HTML code to display

Displays HTML code if the expressions from previous [IF] and [ELSEIF] (if any) are FALSE.

ENDIF

[ENDIF]

Closes an [IF] statement.

Functions

The following functions are supported: MOD

MOD(N,M)
This is a Modulo operation. Returns the remainder of N divided by M.

Example:

[IF MOD(`id`,10) = 5]
 <p>You are a winner!</p>
[ELSE]
 <p>Sorry! Try again!</p>
[ENDIF]