0

I have created an email template on Salesforce Marketing Cloud and I want to add %%FirstName%% personalization string to it. However, I haven't been able to do so after trying different syntaxes. Below is my current syntax:

 %%[
IF Empty(@First Name) OR @First Name == "Unknown" THEN
 set @FirstName = "colleague and friend of NALRC"
ENDIF
]%%

Dear %%=v(@FirstName)=%%,

I would appreciate any help.

1
  • If you are using the above the code in your email template, then in your email use %%=v(@FirstName)=%% – Swati Mishra Jan 25 at 8:14
0

I believe the issue is with the space in the Data Extension column name. I try to avoid spaces in column names as it inevitably causes me problems somewhere. 😃

In this case I used AttributeValue to retrieve the value from the row and UpperCased the Unknown just to be extra safe in case of casing issues.

%%[
var @FirstName

IF Empty(AttributeValue("First Name")) OR Uppercase(AttributeValue("First Name")) == "UNKNOWN" 
THEN 
SET @FirstName = "colleague and friend of NALRC"
ELSE
SET @FirstName = AttributeValue("First Name")
ENDIF

]%%

Dear %%=v(@FirstName)=%%
10
  • Hi Aaron, Thank you for the answer. I copied your code and pasted it, however still not showing up. How can I change field name as you suggested? – Kaveh Ekbia Jan 25 at 1:37
  • What is the Data Extension column name? – Aaron Cates Jan 25 at 1:44
  • The column name is "First Name" – Kaveh Ekbia Jan 25 at 1:47
  • I created a DE in my environment with the "First Name" as a column and it worked with the above code. Are you getting an error or is it just not replacing with tthe Colleague value? – Aaron Cates Jan 25 at 2:04
  • I don't get any error. It is just not replacing. – Kaveh Ekbia Jan 25 at 2:10
0

It could be good practice to use underscores instead of spaces in column names for your target audience. I hope the code below helps in some way.

%%[
VAR @FirstName
SET @FirstName = Trim(AttributeValue("First Name")) 

IF EMPTY(@FirstName) OR @FirstName == "Unknown" THEN
    SET @FirstName = "colleage and friend of NALRC"
ENDIF
]%%
Dear %%=v(@FirstName)=%%,

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.