Skip to main content

Use Cases & Examples

Real-world examples of how businesses use Loyali to drive customer loyalty and increase revenue.


Ecommerce: Shopify Store

Challenge: Low repeat purchase rate (15%), high customer acquisition costs, need to increase customer lifetime value.

Solution: Implement a points-based loyalty program with tiered membership levels.

Implementation

Step 1: Set Up Tiers

# Bronze (default)
POST /api/v1/tiers
{
"name": "Bronze",
"points_threshold": 0,
"multiplier": 1.0,
"benefits": ["Base earning rate"]
}

# Silver
POST /api/v1/tiers
{
"name": "Silver",
"points_threshold": 1000,
"multiplier": 1.25,
"benefits": ["1.25x points", "Free shipping on orders $50+"]
}

# Gold
POST /api/v1/tiers
{
"name": "Gold",
"points_threshold": 5000,
"multiplier": 1.5,
"benefits": ["1.5x points", "Free shipping always", "Early access to sales"]
}

Step 2: Create Rewards

POST /api/v1/rewards
{
"title": "$10 Off Your Next Order",
"points_cost": 1000,
"reward_type": "digital",
"description": "Discount code delivered instantly"
}

POST /api/v1/rewards
{
"title": "Free Shipping",
"points_cost": 500,
"reward_type": "digital"
}

Step 3: Award Points on Purchase

// In your Shopify order webhook handler
async function handleOrderComplete(order) {
// Find or create customer
const customer = await loyali.customers.findOrCreate({
email: order.customer.email,
external_reference: order.customer.id.toString()
});

// Award points: 1 point per dollar spent
const points = Math.floor(order.total_price);

await loyali.points.transaction({
customer_id: customer.id,
amount: points,
type: "earn",
description: `Purchase - Order #${order.order_number}`,
reference: `order_${order.id}`
});

// Check if tier upgrade happened
const updatedCustomer = await loyali.customers.get(customer.id);
if (updatedCustomer.tier_changed) {
// Send congratulations email
await sendTierUpgradeEmail(updatedCustomer);
}
}

Step 4: Display Points in Customer Account

// Using JavaScript SDK
import { Loyali } from 'loyali-sdk';

const loyali = new Loyali({
publicKey: 'pk_live_YOUR_KEY'
});

// In customer account page
const customer = await loyali.identify({
external_reference: shopifyCustomerId
});

// Display points balance
document.getElementById('points-balance').textContent =
`${customer.points_balance} points`;

// Show tier status
document.getElementById('tier-status').textContent =
customer.tier?.name || 'Bronze';

Results

  • 32% increase in repeat purchase rate (15% → 20%)
  • 18% boost in average order value
  • 25% of customers reached Silver tier within 3 months
  • $45,000 additional revenue in first quarter

SaaS: Subscription Service

Challenge: High churn rate (8% monthly), need to reward long-term customers and drive referrals.

Solution: Points for subscription milestones, referral bonuses, and usage-based rewards.

Implementation

Step 1: Create Event Types

POST /api/v1/event-types
{
"name": "subscription_renewed",
"display_name": "Subscription Renewed",
"default_points": 100
}

POST /api/v1/event-types
{
"name": "referral_signup",
"display_name": "Referral Signup",
"default_points": 500
}

POST /api/v1/event-types
{
"name": "feature_used",
"display_name": "Feature Used",
"default_points": 10
}

Step 2: Set Up Tiers Based on Subscription Length

# Active Subscriber (1+ months)
POST /api/v1/tiers
{
"name": "Active",
"points_threshold": 0,
"multiplier": 1.0
}

# Loyal Member (6+ months)
POST /api/v1/tiers
{
"name": "Loyal",
"points_threshold": 600, # 6 months × 100 points
"multiplier": 1.2,
"benefits": ["20% bonus points", "Priority support"]
}

# Champion (12+ months)
POST /api/v1/tiers
{
"name": "Champion",
"points_threshold": 1200, # 12 months × 100 points
"multiplier": 1.5,
"benefits": ["50% bonus points", "Exclusive features", "Beta access"]
}

Step 3: Award Points on Subscription Events

# In your subscription webhook handler
def handle_subscription_renewed(subscription):
customer = loyali.customers.find_by_external_reference(
subscription.customer_id
)

# Award renewal points
loyali.events.create(
customer_id=customer.id,
event_type="subscription_renewed",
properties={
"plan": subscription.plan_name,
"billing_cycle": subscription.billing_cycle,
"months_active": subscription.months_active
},
reference=f"renewal_{subscription.id}"
)

# Bonus for milestones
if subscription.months_active == 6:
loyali.points.transaction(
customer_id=customer.id,
amount=200, # Bonus milestone points
type="earn",
description="6-month milestone bonus"
)
elif subscription.months_active == 12:
loyali.points.transaction(
customer_id=customer.id,
amount=500, # Bigger bonus
type="earn",
description="1-year milestone bonus"
)

Step 4: Handle Referrals

def handle_referral_signup(referrer_id, new_customer_id):
referrer = loyali.customers.find_by_external_reference(referrer_id)
new_customer = loyali.customers.find_by_external_reference(new_customer_id)

# Award referrer
loyali.events.create(
customer_id=referrer.id,
event_type="referral_signup",
properties={
"referred_customer_id": new_customer.id,
"referred_email": new_customer.email
},
reference=f"referral_{new_customer.id}"
)

# Award new customer welcome bonus
loyali.points.transaction(
customer_id=new_customer.id,
amount=100,
type="earn",
description="Welcome bonus"
)

Step 5: Create Subscription Rewards

POST /api/v1/rewards
{
"title": "1 Month Free",
"points_cost": 2000,
"reward_type": "digital",
"description": "Free month added to your subscription"
}

POST /api/v1/rewards
{
"title": "Upgrade to Annual Plan",
"points_cost": 1500,
"reward_type": "digital",
"description": "Discount code for annual plan upgrade"
}

Results

  • 35% reduction in churn rate (8% → 5.2%)
  • 42% increase in referral signups
  • 28% of customers reached "Loyal" tier
  • $120,000 saved in customer acquisition costs

Retail: Multi-Channel Chain

Challenge: Disconnected online and in-store experiences, need unified loyalty program.

Solution: Single loyalty program that works across all channels with real-time sync.

Implementation

Step 1: Unified Customer Identification

// Use phone number or email as primary identifier
async function identifyCustomer(phoneOrEmail, channel) {
let customer;

// Try to find existing customer
try {
customer = await loyali.customers.findByEmail(phoneOrEmail);
} catch {
try {
customer = await loyali.customers.findByPhone(phoneOrEmail);
} catch {
// Create new customer
customer = await loyali.customers.create({
email: phoneOrEmail.includes('@') ? phoneOrEmail : null,
phone: phoneOrEmail.includes('@') ? null : phoneOrEmail,
metadata: {
signup_channel: channel,
signup_date: new Date().toISOString()
}
});
}
}

return customer;
}

Step 2: Award Points from POS System

# In-store POS integration
def process_in_store_purchase(transaction):
customer = identify_customer(
transaction.customer_phone,
channel="in-store"
)

# Award points: 1 point per dollar
points = int(transaction.total_amount)

loyali.points.transaction(
customer_id=customer.id,
amount=points,
type="earn",
description=f"In-store purchase - Receipt #{transaction.receipt_number}",
reference=f"pos_{transaction.id}",
metadata={
"store_location": transaction.store_id,
"cashier": transaction.cashier_id,
"items": transaction.items
}
)

Step 3: Award Points from Online Orders

// Ecommerce integration
async function processOnlineOrder(order) {
const customer = await identifyCustomer(
order.customer.email,
channel="online"
);

const points = Math.floor(order.total);

await loyali.points.transaction({
customer_id: customer.id,
amount: points,
type: "earn",
description: `Online order - Order #${order.number}`,
reference: `online_${order.id}`,
metadata: {
shipping_method: order.shipping_method,
items: order.line_items
}
});
}

Step 4: Cross-Channel Rewards

# Reward that works everywhere
POST /api/v1/rewards
{
"title": "$25 Gift Card",
"points_cost": 2500,
"reward_type": "digital",
"description": "Use online or in-store",
"metadata": {
"usable_channels": ["online", "in-store"],
"expires_days": 365
}
}

Step 5: Real-Time Balance Check

// In-store: Check balance before checkout
async function checkCustomerBalance(phoneNumber) {
const customer = await identifyCustomer(phoneNumber, "in-store");
const summary = await loyali.customers.getSummary(customer.id);

return {
points: summary.points.balance,
tier: summary.tier.current?.name,
canRedeem: summary.points.balance >= 500 // Minimum redemption
};
}

// Display in POS system
const balance = await checkCustomerBalance(customerPhone);
console.log(`${balance.points} points available`);
console.log(`Tier: ${balance.tier}`);

Results

  • 40% increase in cross-channel engagement
  • 55% boost in store visits from online customers
  • 30% increase in online orders from in-store customers
  • Unified customer view across all channels

Marketplace: Multi-Vendor Platform

Challenge: Need to reward customers while also incentivizing vendors to participate.

Solution: Dual-sided loyalty program with customer points and vendor rewards.

Implementation

Step 1: Create Vendor-Specific Rewards

# Vendor A offers
POST /api/v1/rewards
{
"title": "10% Off Vendor A",
"points_cost": 500,
"reward_type": "digital",
"metadata": {
"vendor_id": "vendor_a",
"discount_code": "LOYAL10A"
}
}

# Vendor B offers
POST /api/v1/rewards
{
"title": "Free Shipping from Vendor B",
"points_cost": 300,
"reward_type": "digital",
"metadata": {
"vendor_id": "vendor_b",
"discount_code": "FREESHIPB"
}
}

Step 2: Award Points with Vendor Attribution

def process_marketplace_order(order):
customer = loyali.customers.find_by_external_reference(
order.customer_id
)

# Award points: 1 point per dollar
points = int(order.total)

loyali.points.transaction(
customer_id=customer.id,
amount=points,
type="earn",
description=f"Purchase from {order.vendor_name}",
reference=f"order_{order.id}",
metadata={
"vendor_id": order.vendor_id,
"vendor_name": order.vendor_name,
"category": order.category
}
)

# Track vendor performance
track_vendor_metrics(order.vendor_id, points)

Step 3: Vendor-Specific Tiers

# Create vendor loyalty tiers
POST /api/v1/tiers
{
"name": "Vendor A VIP",
"points_threshold": 2000,
"multiplier": 1.3,
"benefits": [
"30% bonus points on Vendor A purchases",
"Exclusive Vendor A deals"
],
"metadata": {
"vendor_specific": true,
"vendor_id": "vendor_a"
}
}

Results

  • 28% increase in repeat purchases
  • 45% of vendors actively participating in program
  • 22% boost in average order value
  • Strong vendor retention due to increased sales

Mobile App: Gaming/Entertainment

Challenge: Need to gamify user engagement, reward daily logins, and drive in-app purchases.

Solution: Gamified loyalty program with daily check-ins, achievement badges, and in-app rewards.

Implementation

Step 1: Daily Check-In Event

// Award points for daily login
async function handleDailyLogin(userId) {
const customer = await loyali.customers.findByExternalReference(userId);

// Check if already checked in today
const today = new Date().toISOString().split('T')[0];
const recentEvents = await loyali.events.list({
customer_id: customer.id,
event_type: "daily_checkin",
since: today
});

if (recentEvents.length === 0) {
// First check-in today
await loyali.events.create({
customer_id: customer.id,
event_type: "daily_checkin",
properties: {
streak_days: calculateStreak(customer.id),
day_of_week: new Date().getDay()
},
reference: `checkin_${today}_${userId}`
});

// Bonus for streaks
const streak = calculateStreak(customer.id);
if (streak >= 7) {
await loyali.points.transaction({
customer_id: customer.id,
amount: 50, // Weekly bonus
type: "earn",
description: "7-day streak bonus"
});
}
}
}

Step 2: Achievement System

# Create achievement rewards
POST /api/v1/rewards
{
"title": "Level 10 Badge",
"points_cost": 0, # Free, earned not purchased
"reward_type": "achievement",
"metadata": {
"achievement_type": "level",
"level_required": 10
}
}

Step 3: In-App Purchase Rewards

// Award bonus points for in-app purchases
async function handleInAppPurchase(userId, purchase) {
const customer = await loyali.customers.findByExternalReference(userId);

// Base points: 10% of purchase value
const basePoints = Math.floor(purchase.amount * 0.1);

// Bonus for premium purchases
const bonus = purchase.is_premium ? 100 : 0;

await loyali.points.transaction({
customer_id: customer.id,
amount: basePoints + bonus,
type: "earn",
description: `In-app purchase: ${purchase.item_name}`,
reference: `iap_${purchase.transaction_id}`
});
}

Results

  • 65% increase in daily active users
  • 40% boost in in-app purchase conversion
  • 28-day retention improved by 35%
  • Strong engagement with achievement system

Next Steps

Ready to implement your own loyalty program?

  1. Follow the Quick Start Guide to get set up
  2. Read Best Practices to optimize your program
  3. Explore the API Reference for technical details
  4. Contact Support if you need help