SMFC AMPscript IF Condition - 10 Real-Time Use Cases
The AMPscript IF Condition is one of the most commonly used personalization techniques in Salesforce Marketing Cloud (SFMC). It enables marketers to display different content to subscribers based on specific criteria such as customer status, location, age, loyalty tier, subscription plan, or any other data stored in a Data Extension.
Using conditional logic, AMPscript evaluates whether a condition is TRUE or FALSE and dynamically displays the appropriate content. This helps create highly personalized and relevant email experiences, improving customer engagement and campaign effectiveness.
In this blog, we'll explore 10 practical AMPscript IF Condition use cases that demonstrate how to personalize email content based on subscriber attributes and data-driven rules.
Data Extension:
1. Gold Customer:
Code:
%%[Set @Status=AttributeValue("Status")]%%
%%[IF @Status=="Gold" Then]%%
Welcome Gold Member!
%%[ENDIF]%%
Gold Customer
Bronze/ Silver Customer > No output
2. Age Eligibility
Code:
%%[Set @Age=AttributeValue("Age")]%%
%%[IF @Age >=18 Then]%%
You are Eligible
%%[ENDIF]%%
Output: You are Eligible
No Output
3. India Customer
Code:
%%[Set @Country=AttributeValue("Country")]%%
%%[IF @Country =="India" Then]%%
Free Shipping
%%[ENDIF]%%
Output: Free Shipping
4: Birthday
Code:
%%[Set @IsBirthday=AttributeValue("IsBirthday")]%%
%%[IF @IsBirthday=="True" THEN]%%
Happy Birthday!
%%[ENDIF]%%
Output:
5. Cart Value
Code
%%[Set @CartValue=AttributeValue("CartValue")]%%
%%[If @CartValue>="2000" THEN]%%
Extra Rewards
%%[ENDIF]%%
6. Email Exists
Code
%%[Set @Email=AttributeValue("Email")]%%
%%[IF NOT EMPTY (@Email) THEN]%%
Email Verified
%%[ENDIF]%%
Output:
7. Premium Plan
Code
%%[Set @Plan=AttributeValue("Plan")
%%[IF @Plan=="Premium" Then]%%
Premium Content
%%[ENDIF]%%
Output:
In the same, using the ELSE Code:
%%[Set @Plan=AttributeValue("Plan")
%%[IF @Plan=="Premium" Then]%%
Premium Content
%%[ELSE]%%
No Content
%%[ENDIF]%%
8. High Salary
Code
%%[Set @Salary=AttributeValue("Salary")]%%
%%[IF @Salary>="5000" THEN]%%
Bonus
%%[ENDIF]%%
Output:
9. Active Customer
%%[Set @CustomerStatus=AttributeValue("CustomerStatus")]%%
%%[IF @CustomerStatus=="Active" THEN]%%
Special Offer
%%[ENDIF]%%
Output:
10. Mobile Exists
Code
%%[Set @Mobile=AttributeValue("Mobile")]%%
%%[IF NOT EMPTY (@Mobile) THEN]%%
SMS Enabled
%%[ENDIF]%%
Output
If mobile number exists, you will see output as "SMS Enabled"
Takeaways:
Common Mistakes to Avoid Missing ENDIF.
Comments
Post a Comment