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
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]%%
-
I'd suggest wrapping your
Gender
profile attribute/DE column in theAttributeValue()
function:set @Gender = AttributeValue("Gender")
. Your scripting will fail ifGender
doesn't exist. TheAttributeValue()
function will just return an empty string in that case. Commented Dec 8, 2015 at 16:39