Whitepaper

Edge-Computed Behavioral Intelligence

26 real-time scoring models, p95 under 3ms per event (CI-enforced). Feature extraction pipeline, 4-phase model architecture, and dual dataset approach.

ClickStream Research · March 2026 · 22 min read

Abstract

Traditional analytics platforms collect events and process them in batch, often hours or days after the interaction occurred. ClickStream takes a fundamentally different approach: 26 behavioral scoring models execute at the edge — in the same Cloudflare Worker that processes the incoming event — with a CI-enforced benchmark holding the full scoring pass under 3 milliseconds at p95, and zero origin server round-trips. This whitepaper details the feature extraction pipeline, the behavioral features contract, the 4-phase model architecture (core, psychological, predictive, contextual), the dual dataset approach — a raw events dataset and a dedicated scores dataset, both on Cloudflare Analytics Engine — and the documented blob/double field allocation. Every behavioral signal is computed before the HTTP response is returned to the client.

What This Means for You

When you open the Intelligence tab in your ClickStream dashboard at einstein.clickstream.com, you see 26 real-time behavioral scores updating for every active visitor (behavioral scoring models unlock on paid plans, Growth and above). Those scores are computed at the Cloudflare edge closest to each visitor, in milliseconds, as each event is ingested. You don't need to configure or deploy anything; the platform handles it all. This whitepaper explains the architecture that makes it possible.

Table of Contents

  1. Why Edge Computing for Behavioral Analytics
  2. Feature Extraction Pipeline
  3. The BehavioralFeatures Interface
  4. Phase 1: Core Models (5 Models)
  5. Phase 2: Psychological Models (4 Models)
  6. Phase 3: Predictive Models (7 Models)
  7. Phase 4: Contextual Models (10 Models)
  8. Dual Dataset Architecture
  9. Analytics Engine Schema
  10. Performance Benchmarks
  11. Conclusion

1. Why Edge Computing for Behavioral Analytics

Behavioral intelligence loses value with latency. A frustration score computed 24 hours after a user rage-quit your checkout flow cannot prevent the abandonment. An intent signal processed in a batch pipeline cannot trigger a real-time personalization. The value of behavioral signals decays exponentially with time.

ClickStream processes all behavioral scoring at the edge for three reasons:

Behavioral intelligence is not a data warehouse query. It is a real-time signal that must be computed, stored, and actionable within the same HTTP request-response cycle that captures the raw event.

2. Feature Extraction Pipeline

Every incoming event passes through a feature extraction pipeline before any scoring model executes. The pipeline transforms raw event data into normalized features:

2.1 Raw Event Input

The SDK sends a structured event payload with every interaction. The example below is a representative payload — illustrative of the shape, not the literal wire format:

// Representative event payload (illustrative) { "visitorId": "v_m2x7k9p4q_3f8h2j1n9", "event": "page_view", "url": "/pricing", "referrer": "/features", "timestamp": 1710000000000, "scrollDepth": 0.72, "timeOnPage": 45200, "clickCount": 8, "mouseDistance": 4521, "mouseVelocity": 2.3, "scrollVelocity": 1.8, "rageClicks": 0, "deadClicks": 1, "formInteractions": 3, "inputFieldTime": 12400, "errorEncountered": false, "sessionPageCount": 5, "sessionDuration": 234000, "deviceType": "desktop", "viewport": { "width": 1440, "height": 900 } }

2.2 Feature Normalization

Raw values are normalized to 0–1 scales using domain-specific ranges. The examples below are simplified for illustration:

Raw Feature Normalization Range
scrollDepth Already 0–1 [0, 1]
timeOnPage log(ms) / log(600000) [0, 1] (capped at 10 min)
clickCount min(clicks / 20, 1) [0, 1]
mouseVelocity min(velocity / 10, 1) [0, 1]
rageClicks min(rageClicks / 5, 1) [0, 1]
sessionPageCount min(pages / 15, 1) [0, 1]
formInteractions min(interactions / 10, 1) [0, 1]

3. The BehavioralFeatures Interface

All extracted and normalized features are structured into a BehavioralFeatures interface that serves as the input contract for all 26 scoring models. The interface shown here is simplified for illustration — the production contract is richer and evolves with the SDK:

interface BehavioralFeatures { // Engagement signals scrollDepth: number; // 0-1, how far user scrolled timeOnPage: number; // normalized log scale clickCount: number; // normalized 0-1 sessionPageCount: number; // normalized 0-1 sessionDuration: number; // normalized log scale // Mouse dynamics mouseDistance: number; // total pixels traveled, normalized mouseVelocity: number; // average px/ms, normalized mouseAcceleration: number; // velocity change rate, normalized cursorReversals: number; // direction changes, normalized // Frustration indicators rageClicks: number; // rapid clicks on same element deadClicks: number; // clicks producing no response errorEncountered: boolean; // JS errors or HTTP errors scrollVelocity: number; // rapid scrolling = frustration // Form interaction formInteractions: number; // field focus/blur count inputFieldTime: number; // total time in form fields formCompletionRate: number; // fields filled / total fields // Navigation context pageCategory: string; // pricing, product, blog, etc. entrySource: string; // organic, paid, direct, social isReturning: boolean; // has previous sessions daysSinceLastVisit: number; // normalized 0-1 deviceType: string; // desktop, mobile, tablet }

4. Phase 1: Core Models (5 Models)

Phase 1 models evaluate the fundamental behavioral signals that apply to every visitor on every page. They execute first because the later phases build on their outputs.

# Model Output Use Case
1 Intent Classification 0–100 score + stage: browsing, researching, evaluating, or converting Lead scoring, sales prioritization, real-time chat triggers
2 Frustration Detection 0–100 score + list of contributing signals UX problem detection, bug prioritization, support escalation triggers
3 Engagement Scoring 0–100 score + attention seconds (meaningful interaction time) Content optimization, audience segmentation
4 Value Prediction Long-term value score + conversion probability Prospect prioritization, ad spend allocation
5 Anomaly Detection Anomaly score + anomaly type Traffic-quality monitoring, data integrity protection

Engagement Score Algorithm

The engagement score uses a weighted combination of normalized features. The snippet below is simplified for illustration — production weights are tunable per site via ClickStream's scoring configuration:

function calculateEngagement(features: BehavioralFeatures): number { const weights = { scrollDepth: 0.25, timeOnPage: 0.30, clickCount: 0.20, sessionPageCount: 0.15, mouseDistance: 0.10 }; let score = features.scrollDepth * weights.scrollDepth + features.timeOnPage * weights.timeOnPage + features.clickCount * weights.clickCount + features.sessionPageCount * weights.sessionPageCount + features.mouseDistance * weights.mouseDistance; // Bonus for returning visitors if (features.isReturning) score *= 1.15; // Cap and scale to 0-100 return Math.min(Math.round(score * 100), 100); }

Frustration Score Algorithm

The frustration score is critical for real-time UX monitoring — the Signals helper treats scores of 60 and above as a struggling visitor. Again, simplified for illustration:

function calculateFrustration(features: BehavioralFeatures): number { let score = 0; // Rage clicks are the strongest frustration signal score += features.rageClicks * 35; // Dead clicks indicate broken UI elements score += features.deadClicks * 20; // Errors compound frustration if (features.errorEncountered) score += 25; // Rapid scrolling = scanning, not reading = frustrated search if (features.scrollVelocity > 0.7) score += 15; // Excessive cursor reversals = confusion score += features.cursorReversals * 5; return Math.min(Math.round(score), 100); }

5. Phase 2: Psychological Models (4 Models)

Phase 2 models infer higher-order psychological states from the combination of Phase 1 outputs and raw features. These models require more context and produce signals that are useful for personalization and content strategy.

# Model Output Use Case
6 Confusion Detection Confusion score + type: lost, overwhelmed, searching, or stuck Navigation fixes, contextual help triggers, IA optimization
7 Emotional State One of 8 states (curious, engaged, frustrated, confused, excited, decisive, hesitant, neutral) + confidence Tone-matched personalization, content strategy
8 Decision Confidence Confidence score + decision stage CTA timing optimization, offer presentation triggers
9 Regret Detection Post-conversion regret risk Churn-prevention follow-up, refund-risk mitigation

Decision Confidence Algorithm

Decision confidence combines intent with behavioral signals that indicate a visitor is moving toward a conversion event. Simplified for illustration — production weights are per-site tunable:

function calculateDecisionConfidence( features: BehavioralFeatures, intent: number ): number { let score = intent * 0.4; // Pricing page visit is a strong decision signal if (features.pageCategory === 'pricing') score += 25; // Form interaction shows active consideration score += features.formInteractions * 8; // Multiple sessions = research complete if (features.isReturning && features.daysSinceLastVisit < 0.2) score += 15; // High form completion = nearly decided score += features.formCompletionRate * 20; return Math.min(Math.round(score), 100); }

6. Phase 3: Predictive Models (7 Models)

Phase 3 models produce forward-looking predictions about visitor behavior, building on Phase 1 and Phase 2 outputs.

# Model Output Use Case
10 Churn Prediction Churn risk + confidence + risk factors + retention signals Retention campaigns, win-back triggers
11 Purchase Timing Conversion proximity + urgency + session phase Sales notification, follow-up cadence
12 LTV Scoring LTV score + tier + confidence Customer segmentation, ad spend allocation
13 Abandonment Detection Abandonment probability + stage + intervention recommendation Cart and checkout rescue, exit-intent calibration
14 Content Affinity Affinity strength + content type + pattern Content recommendation, personalized navigation
15 Form Friction Friction score + friction type + signals Form optimization, field-level UX fixes
16 Next Action Prediction Predicted action + confidence + alternatives Journey orchestration, preemptive personalization

7. Phase 4: Contextual Models (10 Models)

Phase 4 rounds out the 26-model inventory with contextual and traffic-quality intelligence — session-level quality, campaign and device context, and the behavioral half of bot detection.

# Model What It Captures
17Scroll-Depth IntelligenceHow deeply and meaningfully content is consumed
18Session QualityOverall quality of the session's interactions
19Conversion ReadinessHow close the session is to a conversion event
20Bot Detection ScoreBehavioral bot likelihood (see below)
21Navigation PatternPage-transition patterns across the session
22Return VisitorReturning-visitor behavior and cadence
23Campaign ResponseHow the visitor responds to the acquiring campaign
24Device EngagementEngagement in the context of device type
25Time-of-Day AffinityWhen this visitor engages best
26Loyalty TrajectoryDirection of the visitor relationship over time

Two additional metrics are computed inline by the scoring orchestrator rather than as standalone models: session momentum (−100 to 100) and navigation entropy (Shannon entropy of page-transition patterns).

Bot Detection Is Two-Layer

The Phase 4 bot-detection model contributes the behavioral half of ClickStream's bot verdict — it protects the integrity of all other scores. In production, bot detection is two-layer: a per-request bot score, built from Cloudflare Bot Management signals, a registry of 158 named bots across 8 categories (including 38 named AI agents), datacenter-ASN checks, and header-inconsistency analysis, is reconciled with the per-session behavioral human-confidence score into a single composite verdict. No single behavioral heuristic decides the outcome.

8. Dual Dataset Architecture

ClickStream writes behavioral data to two complementary datasets, each optimized for different access patterns:

8.1 Analytics Engine (Events Dataset)

The Events dataset captures every raw interaction. It is append-only, high-throughput, and optimized for aggregation queries. Each write is a single structured event with up to 20 blob (string) fields and 20 double (numeric) fields.

8.2 Analytics Engine (Scores Dataset)

The Scores dataset (clickstream_scores) is a second, dedicated Analytics Engine dataset that stores every computed behavioral score per event, with a fully documented 20-blob/20-double allocation. Relational state — the dashboard, usage metering, and the identity graph — lives separately in Cloudflare D1.

Characteristic Analytics Engine (Events) Analytics Engine (Scores)
Data model Append-only events Append-only score rows
Write pattern Every event (high volume) Every scored event
Query pattern Aggregations, time series Score aggregations, time series
Retention ~90 days (platform retention) ~90 days (platform retention)
Schema 20 blobs + 20 doubles 20 blobs + 20 doubles (documented score allocation)
Best for Dashboards, trends, funnels Behavioral intelligence, score trends

9. Analytics Engine Schema

Each Analytics Engine write carries up to 20 blob (string) fields and 20 double (numeric) fields. The Scores dataset uses a fixed, documented allocation for those fields — the stable interface between the edge worker and the intelligence dashboard. A selection of the documented allocation:

Field Content Range / Format
double2Purchase intent score0–100
double3Frustration score0–100
double7Session momentum−100 to 100
double8Navigation entropyShannon entropy of page transitions
double9AttentionSeconds of meaningful interaction
double15Churn risk0–100
double17LTV scoreNumeric score
double19Composite bot flagReconciled two-layer bot verdict
blob7Frustration signalsContributing signal list
blob14LTV tiere.g. tier_3

Every field in the 20-blob/20-double envelope has a fixed assignment in the scoring service, so dashboards and downstream aggregation can rely on a stable schema for all 26 model outputs.

10. Performance Benchmarks

ClickStream enforces its latency claim in CI: a permanent benchmark gate fails the build if the full 26-model scoring pass exceeds 3 ms at the 95th percentile (10,000 iterations across 5 realistic visitor profiles).

Metric Value
CI benchmark gatep95 < 3 ms for the full scoring pass (the build fails otherwise)
Benchmark workload10,000 iterations × 5 realistic visitor profiles
Individual model spot checks8 models, each held to p95 < 3 ms
Production code budget~2–3 ms per event
Models executed per event26
Event batch size~2 KB every 5 seconds

A CI-enforced p95 under 3 ms means the full 26-model pass fits inside the event-ingest request itself — faster than a single database query in most traditional architectures.

Why Is It So Fast?

11. Conclusion

Edge-computed behavioral intelligence represents a paradigm shift from batch-processed analytics to real-time signal extraction. By executing 26 scoring models at the edge — with a CI-enforced benchmark holding the full pass under 3ms at p95 — ClickStream transforms raw clickstream events into actionable behavioral signals before the HTTP response is returned to the client.

The 4-phase architecture ensures that models build on each other in a dependency chain — core behavioral measurements feed psychological inferences, which in turn power predictive and contextual models. The dual dataset approach (an events dataset for raw interactions, a dedicated scores dataset for the 26-model outputs — both on Analytics Engine) ensures that behavioral data is optimally stored for both dashboarding and behavioral intelligence, while relational state lives in Cloudflare D1.

The practical implications are significant: frustration detection that triggers support chat in real-time, intent scoring that alerts sales teams to high-value prospects while they are still on the site, churn risk signals that activate retention campaigns before the customer disengages, and bot detection that protects ad spend on every page view.

All of this happens at the edge, in the same infrastructure that sets the first-party cookie and resolves the visitor identity. No batch pipeline. No external ML service. No origin server dependency. Just 26 models, a single synchronous pass, and a CI-enforced 3-millisecond budget.

Real-Time Buyer Signals at the Edge

Identify high-intent visitors — scored in milliseconds at the edge — and trigger conversion opportunities before they leave. Turn behavioral data into revenue.

Start free