← Back to all products

Form Analytics

$19

Track form abandonment, completion rates, and field-level drop-off with JSONL event collection.

15 files
PythonMarkdownJSON

Product Preview

Try the interactive reader and demo tools below, or get the full product with all content unlocked.

Interactive Reader (Free Preview) ⚙ Try Demo Tools Download Free Sample

File Structure 15 files

form-analytics/ ├── LICENSE ├── README.md ├── examples/ │ └── sample_events.jsonl ├── free-sample.zip ├── guide/ │ ├── 01_features.md │ ├── 02_cli-reference.md │ ├── 03_analytics-output.md │ └── 04_file-structure.md ├── index.html ├── interactive.html ├── src/ │ ├── __pycache__/ │ │ └── form_analytics.cpython-312.pyc │ └── form_analytics.py └── tests/ ├── __pycache__/ │ └── test_form_analytics.cpython-312-pytest-9.0.2.pyc └── test_form_analytics.py

Documentation Preview README excerpt

Form Analytics

Track form abandonment, completion rates, and field-level drop-off with JSONL event collection. Pure Python, zero dependencies.

Part of the [Form Forge](https://form-forge.codevault.dev) toolkit by CodeVault.

Features

  • 11 event types: form_view, form_start, field_focus, field_blur, field_change, field_error, step_complete, form_submit, form_abandon, form_success, form_error
  • JSONL event collection: append-only log files, one event per line
  • Funnel analysis: track conversion from view to start to submit to success
  • Field-level drop-off: identify which fields cause users to abandon
  • Timing analysis: mean, median, and P90 completion times
  • Sample data generation: create realistic test data for development
  • JSON output mode: machine-readable analytics for dashboards
  • Python 3.10+ stdlib only — no pip installs required

Quick Start


# Generate sample analytics data
python src/form_analytics.py --generate checkout --sessions 50

# Analyze a form's events
python src/form_analytics.py --analyze checkout

# Output as JSON
python src/form_analytics.py --analyze checkout --json

# Run the built-in demo
python src/form_analytics.py --demo

CLI Reference

FlagDescription
--analyze FORM_IDAnalyze events for a specific form
--generate FORM_IDGenerate sample event data
--sessions NNumber of sessions to generate (default: 20)
--events-dir DIRDirectory containing event JSONL files (default: events/)
--jsonOutput analytics as JSON instead of formatted text
--demoGenerate sample data and run analysis

Event Format

Events are stored as JSONL (one JSON object per line):


{"event": "form_view", "form_id": "checkout", "session_id": "abc123", "timestamp": "2026-03-14T10:00:00Z"}
{"event": "form_start", "form_id": "checkout", "session_id": "abc123", "timestamp": "2026-03-14T10:00:02Z"}
{"event": "field_focus", "form_id": "checkout", "session_id": "abc123", "field": "email", "timestamp": "2026-03-14T10:00:03Z"}
{"event": "field_blur", "form_id": "checkout", "session_id": "abc123", "field": "email", "timestamp": "2026-03-14T10:00:08Z"}
{"event": "form_submit", "form_id": "checkout", "session_id": "abc123", "timestamp": "2026-03-14T10:00:30Z"}
{"event": "form_success", "form_id": "checkout", "session_id": "abc123", "timestamp": "2026-03-14T10:00:31Z"}

Event Types

| Event | Description |

... continues with setup instructions, usage examples, and more.

Code Sample .py preview

src/form_analytics.py #!/usr/bin/env python3 """ Form Analytics — Track Form Performance Metrics ================================================= Collect and analyze form interaction data: submission rates, field-level drop-off, abandonment points, completion times, and conversion funnels. Outputs reports as JSON or text. Part of the Form Forge toolkit by DataNest. License: MIT """ from __future__ import annotations import argparse import json import logging import os import statistics import sys from dataclasses import dataclass, field from datetime import datetime, timezone from typing import Any logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s") logger = logging.getLogger(__name__) # --------------------------------------------------------------------------- # Constants # --------------------------------------------------------------------------- EVENTS_DIR = "analytics_events" REPORTS_DIR = "analytics_reports" class EventType: """Standard form analytics event types.""" FORM_VIEW = "form_view" # User saw the form FORM_START = "form_start" # User interacted with first field FIELD_FOCUS = "field_focus" # User focused on a field FIELD_BLUR = "field_blur" # User left a field FIELD_CHANGE = "field_change" # User changed a field value FIELD_ERROR = "field_error" # Validation error on a field STEP_COMPLETE = "step_complete" # Multi-step: completed a step FORM_SUBMIT = "form_submit" # User submitted the form FORM_ABANDON = "form_abandon" # User left without submitting FORM_SUCCESS = "form_success" # Submission succeeded FORM_ERROR = "form_error" # Submission failed @dataclass # ... 396 more lines ...