Posts

Salesforce Marketing Cloud AMPscript Guide: IIF() & IF-ELSE with Real-Time Business Use Cases

Image
  Use Case 1: Personalized Greeting Using IIF() What is the Business Requirement? A company wants to personalize email greetings based on the subscriber's gender. Male subscribers should see Mr. Female subscribers should see Ms. Instead of writing a full IF-ELSE block, we can use the IIF() function to return a value directly. Algorithm START Read Gender IF Gender = Male Display Mr. ELSE Display Ms. END END IIF Syntax IIF(condition, value_if_true, value_if_false) AMPscript Code %%[ VAR @Gender,@Greeting SET @Gender = AttributeValue("Gender") SET @Greeting = IIF(@Gender == "Male","Mr.","Ms.") ]%% %%=v(@Greeting)=%% Expected Output Record 1 Gender = Male Output Mr. Record 2 Gender = Female Output Ms. Use Case 2: Loyalty Member Classification Using IIF() What is the Business Requirement? A company has a loyalty program and wants to display different benefits based on the customer's membership status. Gold Members → Premium...

Salesforce Marketing Cloud AMPscript Conditional Flow

Image
Salesforce Marketing Cloud AMPscript Conditional Flow: Complete Guide with Real-World Use Cases AMPscript conditional statements are used to control personalization, dynamic content, subscriber eligibility, offer assignment, localization, and journey routing in Salesforce Marketing Cloud. These conditions execute on the server before an email is sent, ensuring every subscriber receives relevant content. 1. IF Statement What is IF Statement? The IF statement executes a block of code only when a condition evaluates to TRUE. Syntax %%[ IF condition THEN /* code */ ENDIF ]%%  Eligibility & Compliance Checks (Most Common) Use Case A financial services company wants to show a credit card offer only to customers who are 18 years or older. If the customer is below 18 or the age is unavailable, the offer should be restricted. Business Applications Age-based offers Gambling & betting compliance Alcohol-related campaigns Banking & financial product eligibility COPPA / GDPR cons...