// 01

The Moroccan E-Commerce Landscape

Morocco’s e-commerce sector is not quietly growing — it is accelerating. Year-over-year transaction volume has expanded at 25%, driven by a young, mobile-first population that has bypassed desktop commerce almost entirely. Over 85% of Moroccan online purchases are initiated on a smartphone. That single data point reshapes every assumption about UX, checkout flow, and conversion optimization.

The payment landscape remains fragmented in ways that challenge operators accustomed to European or North American markets. CMI (Centre Monétique Interbancaire) handles card-based online transactions, but credit and debit card penetration remains limited relative to population size. The result: cash on delivery (COD) accounts for roughly 70% of all e-commerce transactions. This is not a temporary quirk — it is a structural feature of the market that any serious operator must build around.

Logistics add a further layer of complexity. Casablanca, Rabat, and Marrakech are well-served by courier networks. But secondary cities — Meknes, Fes, Oujda, Beni Mellal — face longer delivery windows, less reliable address systems, and higher refusal rates at the door. A model trained only on Casablanca data will perform poorly in Fes. Geography is a first-class feature, not an afterthought.

70% of Moroccan e-commerce transactions still end in cash on delivery. Any AI system for this market must model COD as a first-class signal — not an edge case.

// 02

Five AI Applications Actually Being Used

Strip away the hype and there are five concrete AI applications delivering measurable ROI in Moroccan e-commerce operations today.

  • Product recommendation engines: Collaborative filtering built on purchase and browse history. When a customer who bought a specific phone model also consistently buys a particular brand of case, that signal is retrievable at scale. Operators using recommendation layers report 12–18% increases in average order value.
  • Demand forecasting for inventory before peak seasons: Ramadan, the back-to-school period, and Eid al-Adha create demand spikes that are predictable in timing but variable in magnitude by category and region. ML-driven forecasting reduces both stockouts and overstock, particularly in electronics and clothing.
  • Return rate prediction (refused delivery): Which orders are likely to be refused on delivery? This is the highest-leverage prediction problem in Moroccan e-commerce. A model that correctly identifies high-risk orders before dispatch can route them to a confirmation call centre or apply higher scrutiny — cutting COD losses significantly.
  • Dynamic pricing by region and time of day: Purchasing power and willingness to pay vary meaningfully between a customer in Casablanca’s Maarif district and one in a rural commune. Time-of-day signals (late-night mobile browsing correlates with impulse purchases) allow margin optimization without blanket discounting.
  • Customer segmentation for targeted promotions: RFM (Recency, Frequency, Monetary) segmentation is the baseline. Operators running ML-based clustering on enriched customer profiles — including device type, payment method preference, and city tier — build more granular segment structures that make promotional spend more precise.
// 03

The Return and Refusal Problem

In European e-commerce markets, return rates typically run between 8% and 12% on physical goods. In Moroccan COD e-commerce, refused-delivery rates can reach 30–40% in high-risk categories. The customer places an order, the courier arrives, and the customer simply declines to accept — or is unreachable. The operator absorbs the double logistics cost.

This is not a customer service problem. It is a predictive modelling problem. At the moment of order submission, a significant portion of future refusals are statistically foreseeable from features already present in the order record. The question is whether operators are capturing and acting on those features.

A refusal risk model built on Moroccan order data uses a feature set that differs substantially from a standard European return model. Key inputs include:

// REFUSAL PREDICTION MODEL — FEATURE TABLE (PYTHON / PANDAS)
# Feature table for COD refusal risk model
# Target: refused_on_delivery (bool)

features = {
    "customer_order_count":       "int",   # historical orders placed
    "customer_refusal_rate":      "float", # past refusal ratio (0.0–1.0)
    "address_specificity_score":  "float", # NLP score on address completeness
    "city_tier":                  "int",   # 1=Casa/Rabat  2=Fes/Meknes  3=rural
    "product_category":          "str",   # electronics, clothing, beauty...
    "order_value_mad":           "float", # order total in MAD
    "order_hour":                 "int",   # hour of submission (0–23)
    "device_type":                "str",   # mobile / desktop / tablet
    "payment_method":             "str",   # cod / card / wallet
    "days_since_last_order":      "int",   # recency signal
    "promo_code_used":            "bool",  # promo orders refuse more often
    "session_duration_secs":      "int",   # engagement depth before order
}

# Recommended: GradientBoostingClassifier or XGBoost
# Threshold tuning: optimize precision to reduce false positives

A gradient boosting classifier on this feature set, trained on six months of order history, can typically reach 72–78% precision on the refusal class. That is sufficient to flag the top 20% of risky orders for a pre-dispatch confirmation call — reducing COD losses by a measurable margin without alienating confirmed buyers.

// 04

What a Minimal AI Stack Looks Like

The operational AI stack for a Moroccan e-commerce operator does not require enterprise infrastructure. A lean, functional stack covers five components:

  • Order and customer database (PostgreSQL): The foundation. Clean, structured, queryable order history with customer linkage. Without this, every downstream model is unreliable. Start here before anything else.
  • ETL pipeline to clean and structure order history: Raw order data in most Moroccan operations is messy — inconsistent address fields, duplicate customer records, COD status codes that were never standardized. An ETL layer (Python + Airflow or a scheduled script) transforms this into a usable analytical base.
  • Scikit-learn models for demand forecast and return risk: The two highest-ROI models. Demand forecasting feeds procurement and inventory decisions. Return risk prediction reduces COD losses. Both are implementable with standard scikit-learn pipelines. No GPU required.
  • A/B testing framework for recommendation changes: Any change to the recommendation engine or product display logic needs controlled testing. A lightweight A/B framework — even a simple percentage-split at session level — prevents intuition from overriding data and makes improvements provable.
  • Arabic and French NLP for search and reviews: Moroccan customers write in Darija, French, and Modern Standard Arabic, often mixing scripts within a single review. A search system that handles only one language is leaking signal. Multilingual embedding models (CamemBERT for French, CAMeL for Arabic) are available and fine-tuneable.

“The gap between Moroccan e-commerce businesses that scale and those that plateau is not marketing budget. It is data infrastructure — specifically, whether they can answer ‘why are return rates rising in Fes this month?’”

// 05

The Competitive Window Is Narrowing

The Moroccan e-commerce market is not waiting for operators to get comfortable with data. Jumia Morocco has been running algorithmic recommendation and logistics optimization for years. Amazon’s regional expansion puts further pressure on operators competing on product breadth rather than intelligence. Local players — Hmall, Glovo, and category-specific marketplaces — are all investing in operational analytics.

The operators who moved on data infrastructure in 2023 have a measurable advantage today: lower refusal rates, tighter inventory, higher repeat purchase rates. The gap is not yet insurmountable for those who have not started — but it compounds annually.

The 12-month window that remains is specific: operators who build a functioning order database, a basic ETL pipeline, and at least one predictive model before end of 2026 will be positioned to close the gap. Those who wait for a perfect data strategy before starting any data work will find the window has closed.

The question is not whether AI applies to Moroccan e-commerce — it clearly does. The question is which businesses will have the infrastructure to benefit from it, and which will still be explaining why they need to sort out the data first.

Found this useful?

Share this dispatch with your network.

Back to Dispatches
← PREV — DISPATCH #009 Predictive Analytics NEXT — DISPATCH #011 → AI Is Not Magic
E

Written by

The Engrammers

We write practical AI and data intelligence dispatches for operators, builders, and decision-makers in emerging markets. No hype — just systems that work.