KAAL · Behavioural Engagement Engine · Portfolio Showcase
The Engagement Engine
A gamification-driven customer acquisition and retention system built for a South African e-commerce fashion brand.
Applies game design principles — player progression, unlockable content, personalised quest systems — to drive repeat purchase and LTV growth.
Python
SQLite
JavaScript
Shopify API
Klaviyo API
Wilson Score Algorithm
Netlify
Cohort Analysis
2,416
Customers enrolled
Active engagement profiles
3
Engagement tiers
Starter → Member → Elite
66
Locked range products
Gated by tier progression
94%
Recommendation coverage
Customers with predicted next purchase
System overview — what this engine does
The Engagement Engine applies core game design mechanics to a fashion e-commerce platform.
Customers earn tier progression through purchase behaviour, unlocking exclusive products and personalised treatment at each level.
A behavioural graph tracks purchase sequences to predict each customer's next most likely product — delivered as personalised recommendations via automated marketing flows.
Every element maps directly to a game design primitive: tiers = player levels, locked range = unlockable content, recommendations = personalised quests, sequence analysis = player journey mapping.
Tier Progression System
Player levels · spend thresholds · unlock gates
🥉
Starter
2,067 customers · 85.6%
Entry threshold
1+ order · any value
Full public product catalogue
Standard email flows
Welcome sequence
Abandon cart recovery
Progress to MemberTrack orders + LTV
🥈
Member
301 customers · 12.5%
Threshold
2+ orders OR R8,000+ LTV
All Starter benefits
Access to Member-only edits
Early access to new drops
Priority customer service lane
Partial Locked Range access
Progress to EliteTrack repeat depth
🥇
Elite
48 customers · 2.0%
Threshold
4+ orders OR R25,000+ LTV
All Member benefits
Full Locked Range unlocked
Direct Klaviyo VIP flow
First access to limited releases
Personalised styling recommendations
Named VIP tag in Shopify
Maximum tierRetention focus
Tier distribution over time
Locked Range — Unlockable Content Gate
66 products · tier-gated access · game mechanic: unlockable reward
Design pattern borrowed from games
In games, players unlock new zones, weapons, or abilities by reaching progression thresholds.
The Locked Range applies the same mechanic to product access: 66 curated hero products are hidden from the public catalogue and progressively unlocked as customers advance through tiers.
This creates genuine aspiration, increases perceived exclusivity, and rewards loyal customers with tangible access that new customers cannot buy.
Gate mechanic — how access is determined
🔒 Silk Noir Chemise — Elite only
🔒 The Signature Corset — Elite only
🔐 Pearl Satin Set — Member +
🔐 The Luxe Edit Collection — Member +
✓ The Vine — Public
✓ The Soft Pearl — Public
→
Elite
Full access
Member
Partial access
Starter
Public only
Locked range product breakdown
| Tier gate | Products locked | % of catalogue | Avg price |
| Elite only | 24 | 36% | R3,850 |
| Member + | 42 | 64% | R2,640 |
| Public | — | Full catalogue | R1,890 |
Next Chapter — Recommendation Engine
Personalised next purchase · behavioural graph · Klaviyo delivery
Design pattern borrowed from games: personalised quest assignment
In games, the quest system surfaces the most relevant next objective for each player based on their current progress and play style.
This engine analyses each customer's purchase sequence, hero product affinity, and co-purchase patterns to predict their most likely next product.
Recommendations are pushed directly into Klaviyo as personalised flow triggers — each customer receives a different email with their specific predicted product, not a generic promotion.
Customer A — Elite
Customer B — Member
Customer C — Starter
Hero product
Pearl Collection
38% of all-time spend
Days since last order
23 days
Above average recency
Purchase sequence depth
7 transitions
Highly mapped journey
Predicted next
Silk Nightwear
Directed from Pearl → Silk path
Recommendation
Silk Noir Chemise (Elite-gated)
78% of Elite customers who mirror Customer A's Pearl → Bridal → Silk path purchased the Silk Noir Chemise within 35 days. Median days-to-purchase: 18. Triggered via Klaviyo flow "Next Chapter — Elite Silk" with personalised product block.
Engagement score breakdown
Elite · Top 2% of customers
Hero product
Bridal Collection
44% of all-time spend
Days since last order
51 days
Approaching churn window
Purchase sequence depth
3 transitions
Mid-journey mapping
Predicted next
Pearl Satin Set
Bridal → Pearl path (Member gate)
Recommendation
Pearl Satin Set (Member-unlocked)
61% of Member customers with a Bridal entry SKU purchase the Pearl Satin Set within 60 days. Days since last order (51) is inside the median re-purchase window (58 days) — high probability window. Klaviyo flow triggered: "Next Chapter — Member Pearl" with Member-exclusive product access note.
Engagement score breakdown
Member · Top 14% of customers
Hero product
The Soft Pearl
First + only purchase
Days since last order
14 days
In honeymoon window
Purchase sequence depth
1 transition
Journey just starting
Predicted next
The Vine
Top exit from Soft Pearl entry
Recommendation
The Vine (public catalogue)
The Vine is the #1 sequential purchase for Soft Pearl entry customers (Wilson lower bound: 0.52). Honeymoon window (14 days post-purchase) is the optimal trigger window. Klaviyo flow: "Next Chapter — Starter · Your next piece" — includes teaser preview of Member-unlocked products as tier progression incentive.
Engagement score breakdown
System Architecture
Data pipeline · algorithm stack · deployment
Data pipeline — 7 layers
Ingest
Pull all orders, customers, and products from Shopify Admin API. Pull email event data from Klaviyo API.
Python · REST API
Storage
Normalised SQLite database. Customer × order × product × event schema. Incremental refresh.
SQLite · Python
Tier score
RFM scoring per customer. Threshold classification into Starter / Member / Elite. Tag pushed to Shopify.
Python · SQL
Graph
Co-purchase pairs, directional sequences, Wilson lower bound confidence. Recency trend overlay (90d vs all-time).
SQLite · Statistics
Recommend
Per-customer next-purchase prediction. Entry SKU → sequence path matching. Confidence-ranked product list.
Python · SQLite
Deliver
Push personalised next-purchase predictions into Klaviyo customer profiles as custom properties. Trigger automated email flows.
Klaviyo API · Python
Surface
Live HTML dashboards (this system) built from SQLite data. Deployed to Netlify. No server required.
HTML · JS · Netlify
Core algorithm — Wilson score confidence
Product pair recommendations use the Wilson lower bound formula to rank pairs by statistical confidence, not raw co-purchase count. This prevents high-volume products from dominating recommendations regardless of actual affinity.
def wilson_lower(successes, total, z=1.96):
"""Wilson score lower bound for ranking."""
if total == 0: return 0
p = successes / total
centre = p + z**2 / (2*total)
margin = z * (p*(1-p)/total + z**2/(4*total**2))**0.5
denom = 1 + z**2/total
return (centre - margin) / denom
# Applied per product pair:
for a, b, buyers, total in pairs:
score = wilson_lower(buyers, total)
# score = minimum credible co-purchase rate
Engagement score formula
# Engagement Score (0-100)
# Recency: 30 pts — days since last order
# Frequency: 30 pts — order count + interval
# Monetary: 25 pts — LTV vs cohort percentile
# Sequence: 15 pts — graph depth + hero share
def engagement_score(customer):
r = recency_score(customer.days_since_last)
f = frequency_score(customer.order_count)
m = monetary_score(customer.ltv, cohort_p90)
s = sequence_score(customer.graph_depth,
customer.hero_share)
return r + f + m + s # max 100
Commercial Impact
Measured outcomes · repeat purchase · LTV uplift
| Metric |
Baseline (pre-engine) |
With engagement engine |
Delta |
| Repeat purchase rate | 9.1% | 14.4% | +5.3pp |
| Average LTV (repeat customers) | R5,820 | R8,350 | +43% |
| Email flow open rate | 18.2% | 34.6% | +90% |
| Locked range conversion (Elite) | n/a | 22.4% | New mechanic |
| Recommendation acceptance rate | n/a | 31% | New mechanic |