Behavioral Biometrics
v2.1.0 · Human behavior pattern analysis generating ~165 bits of unique entropy from mouse movements, keyboard typing rhythm, scroll behavior, and touch interactions.
Privacy note: The engine does not record actual keystrokes — it only captures timing patterns (key hold duration, inter-key intervals). Single characters are anonymized as "char"; only special keys (Shift, Enter, etc.) retain their names.
Public API — window.__behavioralV2
| Method | Returns | Description |
|---|
start() | void | Begin 5-second data collection |
stop() | void | Stop collection early |
getData() | Object | Get raw behavioral data (mouse, keyboard, scroll, touch) |
generateFingerprint(data) | string | 8-character behavioral hash from collected data |
hasEnoughData() | boolean | Whether minimums are met for fingerprinting |
getState() | Object | Current collection state (counts, timing) |
Collection Configuration
| Parameter | Value | Description |
|---|
collectionDuration | 5,000ms | Auto-stop after 5 seconds |
maxEventsPerType | 100 | Cap per event type to prevent payload overflow |
minMouseEvents | 10 | Minimum mouse events for valid fingerprint |
minKeyEvents | 5 | Minimum keyboard events |
minScrollEvents | 3 | Minimum scroll events |
Collected Data Points
Mouse Events
| Field | Type | Source |
|---|
x, y | number | clientX / clientY |
movementX, movementY | number | Pointer delta |
timestamp | number | Date.now() |
type | string | "move" | "click" |
button | number | Click button index (clicks only) |
Keyboard Events
| Field | Type | Source |
|---|
key | string | "char" (anonymized) or special key name |
duration | number | Key hold time (keydown → keyup) in ms |
timestamp | number | Date.now() at keyup |
Scroll Events
| Field | Type | Source |
|---|
scrollY | number | Absolute scroll position |
deltaY | number | Scroll delta per event |
timestamp | number | Date.now() |
Touch Events
| Field | Type | Source |
|---|
x, y | number | Touch position |
force | number | Touch pressure (0–1, device-dependent) |
type | string | "start" | "move" |
timestamp | number | Date.now() |
Pattern Analysis Metrics
The tracking engine (tracking.js) performs advanced analysis on the raw data before sending it to the backend:
Mouse Metrics
{
avgVelocity: 0.85, // px/ms average cursor speed
velocityVariance: 0.23, // Speed consistency
avgAngleChange: 0.42, // Radians avg direction change
clickCount: 3,
moveCount: 47,
straightLineRatio: 0.15 // % of near-straight movements
// Bot indicator: straightLineRatio > 0.8
}
Keyboard Metrics
{
avgInterval: 185.3, // ms between keystrokes
intervalVariance: 2450.1, // Typing rhythm consistency
avgKeyDuration: 72.5, // ms key hold time
durationVariance: 890.2,
keyCount: 23,
suspiciouslyRegular: false // true if variance < 10 (bot)
}
Scroll Metrics
{
avgDelta: 53.2, // Average scroll delta
deltaVariance: 1205.8,
avgInterval: 312.5, // ms between scroll events
intervalVariance: 8920.3,
eventCount: 8,
uniformDelta: false // true if all deltas identical (bot)
}
Fingerprint Generation
The behavioral fingerprint is an 8-character hex hash derived from:
signature = [
mouseVelocity.toFixed(2),
keyboardRhythm.toFixed(2),
scrollPattern.toFixed(2),
touchSignature.toFixed(2),
mouseEventCount,
keyboardEventCount,
scrollEventCount,
touchEventCount
].join('|');
hash = simpleHash(signature) → 8-char hex
Integration with Tracking Engine
// Automatic flow (triggered by tracking.js):
1. tracking.js sends main event (t=0s)
2. tracking.js calls __behavioralV2.start() (t=0s)
3. Behavioral engine collects for 5s (t=0-5s)
4. tracking.js reads data at t=6s
5. If hasEnoughData() → POST /t with behavioral payload
// The behavioral payload is sent as a SEPARATE request
// with action: "behavioral_analysis"
Backward Compatibility
Legacy globals are maintained for older integrations:
window.__trackBehavioral = startCollection; // Legacy alias
window.__getBehavioralData = getBehavioralData; // Legacy alias
window.__behavioralData → getBehavioralData(); // Getter (copy)