1

I am using the ContentArea() function to pull content blocks into various emails, one of the content blocks is dynamic, this function does not seem to work with dynamic content blocks, I thought about doing an IF/ELSE to pull in the required content dynamically as needed but I was wondering if anyone had any other suggestions.

1 Answer 1

0

That is correct, you would not be able to use the %%=ContentArea()=%% Function to pull a dynamic content area.

If you're looking to retrieve content areas dynamically in this manner, you would want to code this directly in your email. This would be achieved by using IF/ELSE AMPScript Functions. See below for an example and links on these two topics:

The below AMPScript is setting a variable equal to an attribute in your account called [Gender]. You would then pull one content area if Male, another for Female, and another as a default. Hope this helps!

%%[ 
Var @Gender 
Set @Gender = [Gender] 
]%% 

Your Gender:  %%=v(@Gender)=%% 

%%[IF @Gender == "Male" THEN]%% 
%%=ContentArea("20")=%% 
%%[ELSEIF @Gender == "Female" THEN]%% 
%%=ContentArea("22")=%% 
%%[ELSE]%% 
%%=ContentArea("23")=%% 
%%[ENDIF]%% 

AMPScript Syntax Guide

ContentArea Function

1
  • I'd suggest wrapping your Gender profile attribute/DE column in the AttributeValue() function: set @Gender = AttributeValue("Gender"). Your scripting will fail if Gender doesn't exist. The AttributeValue() function will just return an empty string in that case. Commented Dec 8, 2015 at 16:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .