Documentation

Everything you need to install, configure, and query UserActivity.ai.

Installation

Three steps to start tracking:

  1. Sign in at useractivity.ai/dashboard and add your site
  2. Copy the script tag from your dashboard
  3. Paste it into your HTML <head>
<script
  src="https://useractivity.ai/tracker.js"
  data-site="YOUR_SITE_ID"
  defer
></script>

No npm packages, no build step, no configuration. The tracker loads asynchronously (<8KB gzipped), never blocks rendering, and works on any site — React, Vue, Svelte, vanilla HTML, Lovable, Vercel, anywhere.

API Reference

Query behavioral data directly via HTTP. All analysis endpoints require a site_id query parameter and an Authorization: Bearer header with your API key. Find both in your dashboard.

# Quick test — get your site health score
curl -H "Authorization: Bearer YOUR_API_KEY" "https://useractivity.ai/api/v1/health?site_id=YOUR_SITE_ID"

Analysis endpoints

Each endpoint returns structured JSON with scores, breakdowns, and natural-language narratives — designed for AI agent consumption.

EndpointDescription
/api/v1/healthOverall site health — visitor counts, pageviews, top pages
/api/v1/frustrationRage clicks, dead clicks, errors, hesitations — with frustration score
/api/v1/scrollScroll depth distribution, fold engagement, completion rates
/api/v1/sessionSession reconstruction — duration tiers, page sequences, drop-offs
/api/v1/navigationNavigation flow — common paths, entry/exit points, loops
/api/v1/engagementEngagement metrics — return rate, time on page, interaction depth
/api/v1/summaryStats + top pages as a markdown summary
/api/v1/contextFull behavioral context — all 5 scores + issues in one response

Example: frustration analysis

GET /api/v1/frustration?site_id=YOUR_SITE_ID
Authorization: Bearer YOUR_API_KEY

{
  "score": 72,
  "score_breakdown": {
    "rageClickPenalty": -8,
    "deadClickPenalty": -12,
    "errorPenalty": -3,
    "hesitationPenalty": -5
  },
  "narratives": [
    {
      "severity": "warning",
      "summary": "Dead clicks detected on /pricing",
      "detail": "12% of sessions include clicks on non-interactive elements"
    },
    {
      "severity": "critical",
      "summary": "Rage clicks on checkout submit button",
      "detail": "8% of sessions show 3+ rapid clicks on .btn-submit"
    }
  ]
}

Example: full context

GET /api/v1/context?site_id=YOUR_SITE_ID
Authorization: Bearer YOUR_API_KEY

// Returns all 5 analysis scores + top issues in a single response
// Ideal for giving your AI agent complete behavioral context

Infrastructure endpoints

EndpointDescription
GET /api/healthService health check (no auth required)
GET /api/statsEvent statistics for a site (requires auth)
POST /api/eventsEvent ingestion (used by tracker — you don't call this directly)

MCP Server Setup

Connect your AI coding agent to live behavioral data via the Model Context Protocol. Nothing to install — your agent connects directly to the hosted server.

Remote server (recommended)

Add to your project's .mcp.json (Claude Code, Cursor, or any MCP-compatible agent):

{
  "mcpServers": {
    "useractivity": {
      "type": "http",
      "url": "https://useractivity.ai/api/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY"
      }
    }
  }
}

Find your API key in the dashboard under Setup. Works with Claude Code, Claude Desktop, Cursor, and any MCP client that supports HTTP transport.

Local server (alternative)

Run the MCP server locally via npx (requires npm):

{
  "mcpServers": {
    "useractivity": {
      "command": "npx",
      "args": ["@useractivity/mcp-server"],
      "env": {
        "USERACTIVITY_API_KEY": "your-api-key",
        "USERACTIVITY_SITE_ID": "your-site-id"
      }
    }
  }
}

Available tools

ToolDescription
get_site_healthOverall site health — visitor counts, pageviews
get_frustration_signalsRage clicks, dead clicks, errors, hesitations
get_page_summaryPer-page behavioral summary
get_scroll_analysisScroll depth distributions and engagement
get_session_analysisSession reconstruction and analysis
get_navigation_flowCommon paths, drop-offs, loops
get_engagement_metricsDuration, return rate, interaction depth
get_form_analysisForm interactions, abandonment, completion rates
get_page_comparisonSide-by-side behavioral comparison of two pages

Environment variables (local server only)

VariableDescription
USERACTIVITY_API_KEYYour site API key (found in dashboard Settings)
USERACTIVITY_SITE_IDYour site ID (UUID, found in dashboard Settings)

CLI Commands

All commands support --format json for AI agent consumption via bash.

CommandDescription
npx useractivity statusCheck tracking health — confirms events are flowing
npx useractivity healthSite health score with top issues ranked by severity
npx useractivity frustrationRage clicks, dead clicks, form abandonment, U-turns
npx useractivity contextGenerate .useractivity/context.md behavioral summary for AI agents

Event Types

All events are auto-captured. No event taxonomy to design, no custom tracking code to write.

Event TypeDescription
clickUser clicks on any element — captures target, position, timestamp
rage_click3+ clicks within 2 seconds on the same target — signals frustration
dead_clickClick on a non-interactive element — signals confusing affordances
scrollScroll depth, velocity, direction changes, pause points
form_field_focusUser focuses a form field — tracks field index and type
form_field_blurUser leaves a form field — tracks time spent
form_submitForm submission with fields completed vs. total count
form_abandonUser leaves page with incomplete form — captures abandonment field
navigationPage transition — from/to pages, method (link, back button, direct)
errorJavaScript errors and failed network requests during session
hesitationProlonged hover (2s+) without click — signals confusion
u_turnBack-button press or rapid navigation reversal — signals lost users

Privacy

UserActivity.ai is privacy-first by design. Anonymous behavioral patterns only.

What is collected

  • Clicks, scroll depth, form interactions
  • Page navigation paths
  • Viewport size and device type
  • JavaScript errors during sessions
  • Referrer domain (domain only)
  • Anonymized session ID (per-tab, sessionStorage)

What is NOT collected

  • Keystrokes or form field values
  • Names, emails, IP addresses, or any PII
  • Cookies or cross-site tracking
  • Session replay or screen recording
  • User identification or login state
  • Query parameters (stripped by default)

Do Not Track: If navigator.doNotTrack === "1", the tracker does not initialize.

No cookies: Session ID uses crypto.randomUUID(), stored in sessionStorage (dies with the tab).

Data retention: Events auto-deleted after 90 days by default (configurable: 30, 60, 90, 180 days).

Escape hatch: Call window.useractivity.disable() to stop tracking programmatically.

Open source & source-available: The tracker is open source (MIT). Analytical tools are source-available (Elastic License 2.0). Audit exactly what data is collected and transmitted.