Let's add Realtime AI-Powered Personalisation without Cookies

UtkarshUtkarsh
4 min read

Introduction

As privacy regulations tighten and user expectations soar, modern web experiences demand more than just personalization—they demand relevant, secure, and respectful interactions. The good news? You can achieve all of that in real time, without relying on cookies. In this comprehensive guide, we’ll explore how to build a cookie-less, AI-powered personalization system using the MERN stack (MongoDB, Express.js, React.js, Node.js), real-time data streaming, and edge-compatible machine learning.


🚫 Why Avoid Cookies?

Cookies—especially third-party cookies—are becoming obsolete due to:

  • Regulatory Pressure: GDPR, CCPA, and other laws require explicit consent.

  • Browser Policy Changes: Safari and Firefox block third-party cookies; Chrome is phasing them out.

  • User Distrust: Cookie banners are often ignored or rejected.

To future-proof your app, embrace cookie-less alternatives that deliver even richer user experiences.


🎯 The New Paradigm: Realtime, AI-Powered, Privacy-First

Instead of static cookie-based preferences, use real-time contextual learning to:

  • Infer user behavior based on live session data.

  • Adapt UI/UX in real-time using AI.

  • Respect privacy by never storing PII without consent.

We'll use:

  • Device fingerprinting (for anonymous session continuity).

  • Web sockets (for real-time updates).

  • Edge ML models (for client-side intelligence).


🔧 Tech Stack Overview

  • MongoDB Atlas – Flexible document store for user activity and preferences.

  • Express.js – Backend API for event collection and model responses.

  • React.js + Zustand – Adaptive frontend with fast state updates.

  • Node.js – Server logic, stream management, and orchestration.

  • Socket.IO – Bi-directional communication for live personalization.

  • TensorFlow.js / Brain.js – In-browser ML for privacy-focused inference.

  • FingerprintJS – Anonymous ID generation.


🧱 System Architecture Breakdown

1. Anonymous User Identification

Use fingerprinting for anonymous but consistent identification across a session:

import FingerprintJS from '@fingerprintjs/fingerprintjs';
const fp = await FingerprintJS.load();
const { visitorId } = await fp.get();

Send the visitorId to your server for session tracking:

await fetch('/api/identify', {
  method: 'POST',
  body: JSON.stringify({ visitorId }),
  headers: { 'Content-Type': 'application/json' },
});

2. Real-time Event Tracking

Track user interactions (page views, clicks, hovers, scrolls):

useEffect(() => {
  const trackScroll = () => trackEvent('scroll', { depth: window.scrollY });
  window.addEventListener('scroll', trackScroll);
  return () => window.removeEventListener('scroll', trackScroll);
}, []);

On the server (Express.js):

app.post('/api/event', async (req, res) => {
  const { visitorId, type, metadata } = req.body;
  await EventModel.create({ visitorId, type, metadata, timestamp: new Date() });
  res.sendStatus(200);
});

3. Real-time ML Inference

Example: Classify users as "Reader", "Shopper", or "Explorer" based on interaction patterns.

Train a Brain.js model:

const net = new brain.NeuralNetwork();
net.train([
  { input: { scroll: 0.9, click: 0.1 }, output: { reader: 1 } },
  { input: { scroll: 0.2, click: 0.9 }, output: { shopper: 1 } },
]);

Run inference on each event batch:

const result = net.run({ scroll: 0.75, click: 0.25 });

Push this result back to the frontend via Socket.IO:

io.to(visitorId).emit('personalization', result);

📈 Real-World Use Cases

📰 News Portal

  • Detect interest in "Technology" via article reads and time-on-page.

  • Personalize feed in real time to show more tech articles.

  • Promote related podcasts and videos.

🛒 E-Commerce Store

  • New user: Show trending products.

  • After 3-4 clicks: Infer category (e.g., shoes, gadgets).

  • Adjust homepage layout, suggest similar items.

  • Predict urgency based on dwell time → show time-sensitive discounts.

🎮 Game Streaming Platform

  • Track hover time on different stream thumbnails.

  • Predict genre preferences (RPG vs FPS).

  • Adjust homepage tiles to prioritize relevant content.


🧠 Edge AI for Privacy-First Intelligence

Avoid sending raw behavior logs to the server. Instead:

  • Use TensorFlow.js models in the browser.

  • Run predictions client-side.

  • Send only the high-level outcome (e.g., "likely_to_convert": true).

This massively reduces privacy risks while maintaining rich personalization.


🔒 Privacy & Compliance Best Practices

  • Store no PII unless explicitly provided.

  • Use GeoIP only to infer city/region (never exact IP).

  • Display a banner stating: “We personalize anonymously using AI. No cookies used.”

  • Allow users to reset their session or ID.


💡 Bonus: Progressive Personalization Strategy

  1. Cold Start: Show popular/trending content.

  2. Early Signals: Track micro-interactions (hover, scroll depth).

  3. Live Inference: Use edge AI to adapt components.

  4. Persistent Personalization: Re-identify via fingerprint.

  5. Behavioral Decay: Reduce old data weight over time.


🚀 Final Thoughts

Cookie-less, real-time, AI-powered personalization isn’t just possible—it’s better for both users and developers. With the MERN stack and a dash of edge intelligence, you can:

  • Deliver delightful, responsive experiences.

  • Maintain user trust and privacy.

  • Future-proof your stack for post-cookie web.

🔮 The future is private, personal, and powered by real-time AI.


Ready to implement this in your project? Let me know if you'd like a starter template, live demo, or help tuning your models!

0
Subscribe to my newsletter

Read articles from Utkarsh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Utkarsh
Utkarsh

I'm a MERN Stack developer and technical writer that loves to share his thoughts in words on latest trends and technologies. For queries and opportunities, I'm available at r.utkarsh.0010@gmail.com