Salesforce Marketing Cloud AMPscript IF & ELSE Statement
Salesforce Marketing Cloud AMPscript IF Statement – 10 Real-Time Use Cases
1. Gold Customer Welcome Message
Use Case
When a customer belongs to the Gold membership tier, display a special welcome message. This helps provide a personalized experience for premium customers.
Code
%%[
IF @Status == "Gold" THEN
]%%
Welcome Gold Member!
%%[
ENDIF
]%%
Resulting Outcome
| Status | Output |
|---|---|
| Gold | Welcome Gold Member! |
| Silver | No Output |
2. Age Eligibility Check
Use Case
Display eligibility-related content only to users who are 18 years old or above.
Code
%%[
IF @Age >= 18 THEN
]%%
You are eligible.
%%[
ENDIF
]%%
Resulting Outcome
| Age | Output |
|---|---|
| 25 | You are eligible |
| 16 | No Output |
3. India Customer Free Shipping
Use Case
Provide free shipping information only to customers located in India.
Code
%%[
IF @Country == "India" THEN
]%%
Free Shipping
%%[
ENDIF
]%%
Resulting Outcome
| Country | Output |
|---|---|
| India | Free Shipping |
| USA | No Output |
4. Birthday Greeting
Use Case
Show a birthday greeting when the customer's birthday matches the current date.
Code
%%[
IF @IsBirthday == "True" THEN
]%%
Happy Birthday
%%[
ENDIF
]%%
Resulting Outcome
| Birthday Status | Output |
|---|---|
| True | Happy Birthday |
| False | No Output |
5. High Cart Value Reward
Use Case
Reward customers who have added products worth more than ₹5000 to their cart.
Code
%%[
IF @CartValue > 5000 THEN
]%%
Extra Rewards
%%[
ENDIF
]%%
Resulting Outcome
| Cart Value | Output |
|---|---|
| 7000 | Extra Rewards |
| 1000 | No Output |
6. Email Verification Check
Use Case
Verify whether a subscriber has a valid email address before showing email-specific content.
Code
%%[
IF NOT EMPTY(@Email) THEN
]%%
Email Verified
%%[
ENDIF
]%%
Resulting Outcome
| Output | |
|---|---|
| Available | Email Verified |
| Blank | No Output |
7. Premium Plan Content
Use Case
Display exclusive content only for subscribers enrolled in a Premium plan.
Code
%%[
IF @Plan == "Premium" THEN
]%%
Premium Content
%%[
ENDIF
]%%
Resulting Outcome
| Plan | Output |
|---|---|
| Premium | Premium Content |
| Basic | No Output |
8. High Salary Bonus
Use Case
Show bonus-related information to employees earning ₹50,000 or more.
Code
%%[
IF @Salary >= 50000 THEN
]%%
Bonus
%%[
ENDIF
]%%
Resulting Outcome
| Salary | Output |
|---|---|
| 80000 | Bonus |
| 25000 | No Output |
9. Active Customer Offer
Use Case
Send special offers only to customers whose status is Active.
Code
%%[
IF @Status == "Active" THEN
]%%
Special Offer
%%[
ENDIF
]%%
Resulting Outcome
| Status | Output |
|---|---|
| Active | Special Offer |
| Inactive | No Output |
10. Mobile Number Availability
Use Case
Enable SMS communication only when a mobile number is available in the subscriber record.
Code
%%[
IF NOT EMPTY(@Mobile) THEN
]%%
SMS Enabled
%%[
ENDIF
]%%
Resulting Outcome
| Mobile Number | Output |
|---|---|
| Available | SMS Enabled |
| Blank | No Output |
Salesforce Marketing Cloud AMPscript IF ELSE Statement – Real-Time Use Cases
1. Personalized Greeting
Use Case
Display the subscriber's first name when available. If the first name is missing, show a generic greeting.
Code
%%[
IF NOT EMPTY(@FirstName) THEN
]%%
Hello %%=v(@FirstName)=%%,
%%[
ELSE
]%%
Hello Customer,
%%[
ENDIF
]%%
Resulting Outcome
| First Name | Output |
|---|---|
| Raj | Hello Raj |
| Blank | Hello Customer |
2. Loyalty Offer
Use Case
Provide VIP discounts to Gold members and regular discounts to all other customers.
Code
%%[
IF @Status == "Gold" THEN
]%%
VIP Discount
%%[
ELSE
]%%
Regular Discount
%%[
ENDIF
]%%
Resulting Outcome
| Loyalty Status | Output |
|---|---|
| Gold | VIP Discount |
| Silver | Regular Discount |
3. Country-Based Shipping
Use Case
Offer free shipping to customers in India while displaying international shipping information for customers from other countries.
Code
%%[
IF @Country == "India" THEN
]%%
Free Shipping
%%[
ELSE
]%%
International Shipping
%%[
ENDIF
]%%
Resulting Outcome
| Country | Output |
|---|---|
| India | Free Shipping |
| USA | International Shipping |
Comments
Post a Comment