Steps and examples for rendering your dynamic content in Marketing Cloud. Note: This information does not apply to Content Builder generated content.
Follow these steps:
1. Place the following code in a template email (This will allow use of the account-level headers and footers):
%%[
Var @Content_A,@Content_B,@Content_C
Set @Content_A = Test_A
Set @Content_B = Test_B
Set @Content_C = Test_C
]%%
%%[IF @Content_A == 'Yes' THEN]%%
%%=ContentAreaByName("my contents\dynamic\Content_A")=%%
%%[ELSEIF @Content_B == 'Yes' THEN]%%
%%=ContentAreaByName("my contents\dynamic\Content_B")=%%
%%[ELSEIF @Content_C == 'Yes' THEN]%%
%%=ContentAreaByName("my contents\dynamic\Content_C")=%%
%%[ELSE]%%
No content to render.... this would be a subscriber who meets none of the previous criteria..this would be the default content if you wanted to have default content
%%[ENDIF]%%
2. Create three ContentAreas (Content_A, Content_B and Content_C) in the 'My Contents' folder.
Note: The full path to the ContentArea is specified in the ContentAreaByName() function, so "my contents\dynamic\Content_C" is Content_C under the 'Dynamic' subfolder under 'My Contents.' Keep the content simple in HTML (ie: <H1>This is content area A</H1>). This will allow you to test the function with basic content.
3. Create a list and add subscribers who will have just the value for each condition in the code above. Once you have the email, the ContentAreas and the list, you should be able to send preview the email with the test list and see the dynamic content change as you preview each subscriber.
Note: Based on the use of the IF THEN ELSEIF, the ContentArea rendered will be the first one to have a value of 'Yes' in the attribute.
%%[ Var @Content_A,@Content_B,@Content_C Set @Content_A = Test_A Set @Content_B = Test_B Set @Content_C = Test_C ]%%
Creates the variables to contain the values of the attributes Test_A, Test_B, and Test_C and then sets them with the corresponding attribute value. Set @Content_A = Test_A means set the variable @Content_A with the value of Test_A.
This is an IF logic that looks at the value in the variable and then uses the ContentAreaByName function to insert a ContentArea. Currently, if the value falls outside the specified ranges then the information in the ELSE block will be inserted. This logic can be tweaked.
%%[IF @Content_A == 'Yes' THEN]%%
%%=ContentAreaByName("my contents\dynamic\Content_A")=%%
%%[ELSEIF @Content_B == 'Yes' THEN]%%
%%=ContentAreaByName("my contents\dynamic\Content_B")=%%
%%[ELSEIF @Content_C == 'Yes' THEN]%%
%%=ContentAreaByName("my contents\dynamic\Content_C")=%%
%%[ELSE]%%
No content to render.... this would be a subscriber who meets none of the previous criteria
%%[ENDIF]%%000386274

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.