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



StatusOutput
GoldWelcome Gold Member!
SilverNo 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





AgeOutput
25You are eligible
16No 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




CountryOutput
IndiaFree Shipping
USANo 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 StatusOutput
TrueHappy Birthday
FalseNo 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 ValueOutput
7000Extra Rewards
1000No 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



EmailOutput
AvailableEmail Verified
BlankNo 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




PlanOutput
PremiumPremium Content
BasicNo 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




SalaryOutput
80000Bonus
25000No 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




StatusOutput
ActiveSpecial Offer
InactiveNo 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 NumberOutput
AvailableSMS Enabled
BlankNo 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 NameOutput
RajHello Raj
BlankHello 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 StatusOutput
GoldVIP Discount
SilverRegular 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






CountryOutput
IndiaFree Shipping
USAInternational Shipping


Comments

Popular posts from this blog

Mastering CASE Statement in Salesforce Marketing Cloud (SFMC SQL)

A/B Testing in Salesforce Marketing Cloud (Step-by-Step Guide)

๐Ÿ“ง Creating & Sending a Test Email in Salesforce Marketing Cloud (SFMC)