Subject Line Personalization Using AMPscript in Salesforce Marketing Cloud
Code sample to create a subject line with first name and a message if the first name is available otherwise just the message (if the first name is not available). This is a very simple code but when when I first started building emails in the marketing cloud, I had no idea how to do this. Let’s assume, the sendable data extension has a first name column with firstName as the field header. In the subject line field of the email, enter: %%=v(@SLine)=%% AMPscript in email body to declare and populate the @SLine variable: HTML %%[ VAR @SLine SET @SLine = "Here is an exclusive offer for you!" SET @FName = [firstName] If NOT EMPTY (@FName) THEN SET @SLine = CONCAT(@FName,", Here is an exclusive offer for you!") ELSE SET @SLine = "Here is an exclusive offer for you!" ENDIF ENDIF ]%% In this example, if the first name is available, the subject line will be: Firstname, Here is an