Personalized Recommendations Are Here — Powered by Smart Analytics

June 2, 2025

At Simplico, we’re constantly improving the shopping experience for both customers and business owners. Today, we’re excited to introduce a powerful new feature to our eCommerce system:

🎯 Built-in Product Recommendations Based on Real User Behavior

No third-party plugins. No extra setup. Just smarter selling, right out of the box.


🔍 How It Works

Every time someone visits your store, our system tracks their session (anonymously) and records which product pages they view. Over time, this creates a rich dataset of user behavior — without requiring login or cookies.

Then, using machine learning techniques like collaborative filtering, our platform answers one powerful question:

“What other products do people usually view after this one?”


📊 System Diagram

graph TD
    A["Visitor arrives on site"] --> B["UserLogMiddleware records session + URL"]
    B --> C["Product view extracted from URL"]
    C --> D["Session → Product matrix stored"]
    D --> E["AI Model (implicit ALS) trains on data"]
    E --> F["System predicts related products"]
    F --> G["Recommendations shown on product page"]

🧱 Sample Code: How We Log Product Views

# logs/middleware.py

class UserLogMiddleware:
    def __call__(self, request):
        path = request.path
        if "/product/" in path and request.session.session_key:
            from .models import UserLog
            UserLog.objects.create(
                session_key=request.session.session_key,
                url=path
            )
        return self.get_response(request)

🔍 Sample: Extracting Product ID from URL

import re

def extract_product_id(url):
    match = re.search(r"/product/(\d+)/", url)
    return match.group(1) if match else None

🧠 Sample: Building User-Item Matrix for Recommendations

from scipy.sparse import coo_matrix
from collections import defaultdict

# Example view data from logs
logs = UserLog.objects.all()
data = []
session_map, product_map = {}, {}
session_id, product_id = 0, 0

for log in logs:
    session = log.session_key
    product = extract_product_id(log.url)
    if not session or not product:
        continue
    if session not in session_map:
        session_map[session] = session_id
        session_id += 1
    if product not in product_map:
        product_map[product] = product_id
        product_id += 1
    data.append((session_map[session], product_map[product]))

# Build sparse matrix
rows, cols = zip(*data)
matrix = coo_matrix((len(data) * [1], (rows, cols)))

🤖 Sample: Training the Recommendation Model

from implicit.als import AlternatingLeastSquares

model = AlternatingLeastSquares(factors=50, iterations=15)
model.fit(matrix)

🎯 Sample: Get Similar Products for a Product ID

def recommend_similar(product_id, top_n=5):
    index = product_map.get(str(product_id))
    if index is None:
        return []
    similar_items = model.similar_items(index, N=top_n + 1)
    return [pid for pid_idx, _ in similar_items if (pid := get_product_by_index(pid_idx)) != product_id]

def get_product_by_index(index):
    # reverse map from index → product_id
    for pid, idx in product_map.items():
        if idx == index:
            return pid
    return None

🛍️ Example: "Customers Who Viewed This Also Viewed…"

When a user visits the iPhone Case page, the system might recommend:

  • Wireless Charger
  • Tempered Glass Screen Protector
  • Phone Stand
  • iPad Mini Case

These aren’t random — they’re based on thousands of real customer sessions.


⚙️ Built-In and Fully Integrated

  • ✅ No configuration needed
  • ✅ Learns from actual product views
  • ✅ Supports both authenticated and guest users
  • ✅ Automatically improves as more data is collected
  • ✅ Secure and fast (recommendations can be cached)

🚀 Ready to Grow Smarter?

If you’re already on our platform, your product pages may already be showing smarter recommendations.
If you’re not yet using Simplico eCommerce — contact us today and let’s upgrade your storefront together.

Ready to talk about your project?

Share goals and constraints. We'll assemble architects and engineers to move fast with you.

Get in touch