%%=[IF @country == IT then]=%% 

%%=ContentAreaByName("My Contents\3_content_test\test_HEADER\COUNTRY\IT")=%% 

Just i have removed the flower brackets just try it will work out.

I'm trying to built a Content Box using ContentAreaByName function and IF Statement, but it doesn't work. Please find below the code snippet:

%%[VAR @country
SET @country = Country

%%=[IF (@country) == IT then]=%% 
%%=ContentAreaByName("My Contents\3_content_test\test_HEADER\COUNTRY\IT")=%% 

%%=[END IF]=%%

%%=[IF (@country) == FR then]=%% 
%%=ContentAreaByName("My Contents\3_content_test\test_HEADER\COUNTRY\FR")=%% 

%%=[END IF]=%%

When I try to preview in ET I receive this error:

Unable to generate preview

A scripting error has occurred. The function call uses an unrecognized function name. Function Name: [IF Function Call: [IF (@country) == IT then]

Could you point where am I doing wrong? Thank you, Giulia

1 Answer 1


You're missing some quotes in your IF statements. Also, there's no space in ENDIF.

Here's how I usually do these types of conditionals:

VAR @country, @contentPath
SET @country = AttributeValue("Country") /* handles null values */

IF @country == "IT" then
  set @contentPath = "My Contents\3_content_test\test_HEADER\COUNTRY\IT"
elseif @country == "FR" then
  set @contentPath = "My Contents\3_content_test\test_HEADER\COUNTRY\FR"
  set @contentPath = "My Contents\3_content_test\test_HEADER\COUNTRY\DEFAULT"


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.