Whitepaper

Edge-Computed Behavioral Intelligence

26 real-time scoring models processed in under 3ms at the edge. Feature extraction pipeline, 3-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 — completing all scoring in under 3 milliseconds with zero origin server round-trips. This whitepaper details the feature extraction pipeline, the BehavioralFeatures interface, the 3-phase model architecture (core, psychological, predictive), the dual dataset approach using Cloudflare Analytics Engine and D1, and the Analytics Engine schema with blob/double field mapping. 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. Those scores are computed at the Cloudflare edge closest to each visitor — typically within 3ms of the triggering event. 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. Dual Dataset Architecture
  8. Analytics Engine Schema
  9. Performance Benchmarks
  10. 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:

// Raw event payload from SDK { "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. For example:

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:

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 Phase 2 and Phase 3 models depend on their outputs.

# Model Output Range Primary Inputs Use Case
1 Engagement Score 0–100 scrollDepth, timeOnPage, clickCount, sessionPageCount Overall engagement level for content optimization and audience segmentation
2 Frustration Score 0–100 rageClicks, deadClicks, errorEncountered, scrollVelocity, cursorReversals UX problem detection, bug prioritization, support escalation triggers
3 Intent Score 0–100 pageCategory, formInteractions, sessionPageCount, isReturning, timeOnPage Lead scoring, sales prioritization, real-time chat triggers
4 Attention Score 0–100 scrollDepth, timeOnPage, mouseDistance, mouseVelocity Content effectiveness measurement, ad viewability proxy
5 Navigation Fluency 0–100 sessionPageCount, sessionDuration, deadClicks, cursorReversals Site architecture evaluation, information architecture optimization

Engagement Score Algorithm

The engagement score uses a weighted combination of normalized features:

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. Scores above 70 trigger automated alerts:

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 Range Primary Inputs Use Case
6 Cognitive Load 0–100 timeOnPage, scrollVelocity, cursorReversals, mouseAcceleration, Frustration Score Content complexity assessment, readability optimization
7 Decision Readiness 0–100 Intent Score, formInteractions, pageCategory, sessionPageCount, isReturning CTA timing optimization, offer presentation triggers
8 Content Affinity Category vector pageCategory history, timeOnPage per category, scrollDepth per category Content recommendation, personalized navigation
9 Urgency Signal 0–100 sessionDuration, sessionPageCount, formCompletionRate, daysSinceLastVisit Time-sensitive offer triggers, exit-intent calibration

Decision Readiness Algorithm

Decision readiness combines intent with behavioral signals that indicate a visitor is moving toward a conversion event:

function calculateDecisionReadiness( features: BehavioralFeatures, intentScore: number ): number { let score = intentScore * 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. They depend on both Phase 1 and Phase 2 outputs, plus historical patterns when available from D1.

# Model Output Range Primary Inputs Use Case
10 Churn Risk 0–100 Engagement Score trend, daysSinceLastVisit, sessionDuration decline, Frustration Score Retention campaigns, win-back triggers
11 Purchase Timing 0–100 Decision Readiness, Intent Score, pageCategory sequence, formCompletionRate Sales notification, discount timing, follow-up cadence
12 LTV Estimate Tier (1–5) Engagement Score, Content Affinity, sessionPageCount, entrySource, deviceType Customer segmentation, ad spend allocation
13 Bounce Probability 0–100 timeOnPage (first 10s), scrollDepth (first 10s), mouseVelocity, entrySource Exit-intent popup triggers, content above-fold optimization
14 Conversion Probability 0–100 Intent Score, Decision Readiness, formCompletionRate, isReturning, entrySource Real-time bidding signals, personalization prioritization
15 Content Consumption Depth 0–100 Attention Score, scrollDepth, timeOnPage, sessionPageCount, Content Affinity Content strategy, paywall timing, newsletter targeting
16 Bot Probability 0–100 mouseVelocity consistency, clickCount patterns, timing regularity, interaction absence Traffic quality filtering, fraud detection, ad spend protection

Bot Probability Algorithm

Bot detection is a critical Phase 3 model that protects the integrity of all other scores. Bots exhibit distinct behavioral patterns:

function calculateBotProbability(features: BehavioralFeatures): number { let botSignals = 0; // No mouse movement = likely headless browser if (features.mouseDistance === 0 && features.deviceType === 'desktop') { botSignals += 40; } // Perfectly regular timing = scripted if (features.mouseVelocity > 0 && features.mouseAcceleration === 0) { botSignals += 30; // constant velocity = non-human } // Extremely fast page navigation = scripted crawl if (features.sessionPageCount > 0.8 && features.sessionDuration < 0.1) { botSignals += 25; } // No scroll on long pages = likely not rendered if (features.scrollDepth === 0 && features.timeOnPage > 0.3) { botSignals += 15; } // Click without preceding mouse movement if (features.clickCount > 0 && features.mouseDistance === 0) { botSignals += 20; } return Math.min(botSignals, 100); }

7. Dual Dataset Architecture

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

7.1 Cloudflare 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.

7.2 Cloudflare D1 (Scores Dataset)

The Scores dataset stores the computed behavioral scores per visitor per session. It is a relational SQLite database at the edge, optimized for point lookups and visitor-level queries. This is where the identity graph references behavioral data.

Characteristic Analytics Engine (Events) D1 (Scores)
Data model Append-only events Relational (SQL)
Write pattern Every event (high volume) Per session update (lower volume)
Query pattern Aggregations, time series Point lookups, joins
Retention 90 days (auto-scrub) Configurable per customer
Schema 20 blobs + 20 doubles Full SQL schema
Best for Dashboards, trends, funnels Identity resolution, visitor profiles

8. Analytics Engine Schema

The Analytics Engine schema maps behavioral data to the 20 blob and 20 double fields available per event. This mapping is the critical interface between the edge worker and the analytics dashboard:

Blob Fields (Strings)

Field Content Example
blob1Visitor IDv_m2x7k9p4q_3f8h2j1n9
blob2Session IDs_m2x7k9p4r
blob3Event typepage_view
blob4Page URL/pricing
blob5Page categorypricing
blob6Referrer/features
blob7Entry sourceorganic
blob8UTM sourcegoogle
blob9UTM mediumcpc
blob10UTM campaignbrand_2026
blob11Device typedesktop
blob12Country (from CF headers)US
blob13RegionCA
blob14CitySan Francisco
blob15BrowserChrome 125
blob16OSmacOS 15
blob17Ad click ID (gclid/fbclid)EAIaI...
blob18Hashed email (if available)a1b2c3...
blob19Content affinity categoryproduct
blob20LTV tiertier_3

Double Fields (Numerics)

Field Content Range
double1Engagement Score0–100
double2Frustration Score0–100
double3Intent Score0–100
double4Attention Score0–100
double5Navigation Fluency0–100
double6Cognitive Load0–100
double7Decision Readiness0–100
double8Urgency Signal0–100
double9Churn Risk0–100
double10Purchase Timing0–100
double11Bounce Probability0–100
double12Conversion Probability0–100
double13Content Consumption Depth0–100
double14Bot Probability0–100
double15Scroll depth (raw)0–1
double16Time on page (ms)0–600000
double17Click count (raw)0–N
double18Session page count0–N
double19Session duration (ms)0–N
double20Processing time (ms)0–10

double20 is reserved for self-monitoring: it records the total time in milliseconds the edge worker spent computing all 26 scores. This enables real-time performance monitoring of the scoring pipeline itself.

9. Performance Benchmarks

ClickStream measures double20 (processing time) across all edge locations. The results across a 30-day window:

Metric Value
P50 processing time1.2 ms
P90 processing time2.1 ms
P99 processing time2.8 ms
P99.9 processing time4.1 ms
Max observed6.3 ms
Models executed per event26
Features extracted per event22
Average payload size1.8 KB

The P99 of 2.8ms means that 99% of all events across all global edge locations complete all 26 scoring models in under 3ms. This is faster than a single database query in most traditional architectures.

Why Is It So Fast?

10. Conclusion

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

The 3-phase architecture ensures that models build on each other in a dependency chain — core behavioral measurements feed psychological inferences, which in turn power predictive models. The dual dataset approach (Analytics Engine for aggregation, D1 for relational queries) ensures that behavioral data is optimally stored for both dashboarding and identity resolution.

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, 22 features, and under 3 milliseconds.

Real-Time Buyer Signals at the Edge

Identify high-intent visitors in under 3ms and trigger conversion opportunities before they leave. Turn behavioral data into revenue.

GET EARLY ACCESS