Docs · connect any stack

One snippet, one line for your users.
Everything else is optional.

Connect any stack to LyticData. API key required — create a project to get yours.

What LyticData is, in plain English

If an AI wrote most of your app (Cursor, Claude Code, Lovable, Bolt, v0), something in it is throwing for your users right now and nobody is telling you. LyticData catches every error a real browser hits, ties it to your actual signed-up users, and every morning gives you one ranked brief: the thing to fix first, why it is at the top, and the change to make, ready to paste back into your AI editor. An error tool tells you a stack trace fired 47 times; an analytics tool tells you 400 people visited. Neither can tell you that three of the people who hit the bug are on your paid plan. This does that part.

You add one snippet.

Five minutes, no tag manager, no SDK maze.

You add one line for your users.

LyticData.identify(yourUserId) — an opaque id you assign, never a name or an email.

It records what happens.

Pages, journeys, clicks, signups, purchases — and every error a real browser throws, with the stack a developer needs.

You get a morning brief.

Three findings in plain prose, each with the fix — ready to paste into Cursor or Claude Code.

What it will never tell you: that a bug “cost you 9 signups”. We can see who hit an error and who did nothing afterwards; nobody can see what those people would have done otherwise. So you get two measured numbers side by side (“12 hit this, 2 signed up — 17%, against 34% across the week”) and never an invented loss, a dollar figure on an error, or a promise that a fix will lift revenue. The only outcome it promises is the broken thing going quiet.

Supported stacks: Next.js (App + Pages), React, Vue, Vanilla HTML/JS — plus a REST API any backend can call (Python, Ruby, Go, PHP, Rust, .NET…).

1. Get your API key

Go to Dashboard → Add Project → Create new project. Copy the API key — it's shown once on creation. If you lose it, paste it back via Add existing API key on the same screen.

2. Next.js best fit

The Next.js helper auto-tracks API routes and server work (method, route, status, duration, server-side errors) in addition to client-side pageviews. Two pieces — middleware for server tracking, script tag for client tracking.

a) Download the helper into your project

Save it as lib/lyticdata.js in your Next.js repo. (Not on npm yet — single-file install.)

curl http://localhost:3000/api/helpers/nextjs -o lib/lyticdata.js

Or open http://localhost:3000/api/helpers/nextjs and save the file.

b) Set env vars

# .env.local
LYTICDATA_URL=http://localhost:3000
LYTICDATA_API_KEY=YOUR_API_KEY

c) Wrap your middleware (server-side tracking)

// middleware.js (project root)
import { withLyticData } from './lib/lyticdata';

export default withLyticData(); // or withLyticData(yourExistingMiddleware)

export const config = {
  // exclude static assets
  matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
};

d) Add the client script (click map + UTM + client errors)

// app/layout.js
import Script from 'next/script';

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        {children}
        <Script id="lyticdata-config" strategy="beforeInteractive">
          {`window.LYTICDATA_CONFIG = { api: "http://localhost:3000", apiKey: "YOUR_API_KEY" };`}
        </Script>
        <Script src="http://localhost:3000/lyticdata.js" strategy="afterInteractive" />
      </body>
    </html>
  );
}

e) Track server-side events (purchases, signups, cron jobs)

import { trackServer } from './lib/lyticdata';

// After Stripe webhook fires:
await trackServer({
  type: 'event',
  name: 'purchase',
  revenue: 29,
  currency: 'USD',
  clerkId: user.id,
  metadata: { plan: 'pro' },
});

3. React / Vue / Vanilla HTML

Drop two script tags before </body>. Auto-tracks pageviews, UTM, time-on-page, click map (which elements were clicked), scroll depth, and uncaught errors. Client-side route changes are tracked too, so single-page apps report every view — not just the first.

<script>
  window.LYTICDATA_CONFIG = {
    api: "http://localhost:3000",
    apiKey: "YOUR_API_KEY",
    clickMap: true,          // default true — records which elements were clicked
    requireConsent: false,   // set true to hold tracking until grantConsent()
    // userId — optional OPAQUE reference (e.g. a hash of your user id) so you can
    // correlate behavior on your side. Never send names or emails: by design,
    // LyticData stores no end-user PII and ignores any name/email fields.
  };
</script>
<script src="http://localhost:3000/lyticdata.js" async></script>

Click labels are read from interactive elements only. To keep a region out of the click map entirely — an output panel, a generated result, anything showing your user's own data — add data-lytic-ignore to it and nothing inside will be recorded.

4. Custom events

After the script loads, call window.LyticData.track() from anywhere.

window.LyticData.track('signup_started', { plan: 'pro' });
window.LyticData.track('purchase', { revenue: 29, currency: 'USD' });
window.LyticData.track('feature_used', { feature: 'export_csv' });

Event names containing "purchase", "order", "checkout", "payment", or "sale" (or any event with a revenue field) trigger a payment notification.

5. Track errors

The script captures uncaught errors and unhandled promise rejections automatically. To send a caught error manually:

try {
  await doRiskyThing();
} catch (err) {
  window.LyticData.captureError(err);
}

6. REST API — any backend

Anything that can make an HTTPS request can send events. CORS is open; auth is a single header.

POST an event

POST http://localhost:3000/api/events
Content-Type: application/json
X-API-Key: YOUR_API_KEY

{
  "type": "event",
  "name": "purchase",
  "revenue": 29,
  "currency": "USD",
  "url": "https://yoursite.com/checkout",
  "path": "/checkout",
  "visitorId": "user-123",
  "clerkId": "user_abc123",
  "metadata": { "plan": "pro" }
}

curl

curl -X POST http://localhost:3000/api/events \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{"type":"event","name":"signup","clerkId":"user_abc"}'

Python (requests)

import requests

requests.post(
    "http://localhost:3000/api/events",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={
        "type": "event",
        "name": "purchase",
        "revenue": 29,
        "currency": "USD",
        "clerkId": user.id,
    },
)

POST an error

POST http://localhost:3000/api/errors
Content-Type: application/json
X-API-Key: YOUR_API_KEY

{
  "message": "Stripe webhook signature mismatch",
  "stack": "...",
  "url": "https://yoursite.com/api/webhooks/stripe",
  "metadata": { "stripeEventId": "evt_..." }
}

7. Privacy & consent no PII stored

LyticData stores no end-user names, emails, or raw IP addresses — visitors are tracked by a random anonymous ID, location is country/city only, and raw data is deleted after 90 days. See the Privacy Policy and DPA.

Consent gate

Set requireConsent: true and nothing is tracked until you grant consent (e.g. from your cookie banner's "Accept" handler):

// After the visitor accepts:
window.LyticData.grantConsent();
// To stop again:
window.LyticData.revokeConsent();

Erase a user (right to erasure)

Delete all of one end-user's data within your project. Call this from your backend when a user requests deletion.

POST http://localhost:3000/api/erase
X-API-Key: YOUR_API_KEY
Content-Type: application/json

{ "visitorId": "the-anonymous-id", "externalId": "your-user-ref" }

Export / delete a whole project

From the dashboard project switcher: Export downloads all of a project's data as JSON; Delete data permanently erases it and disconnects the project.

8. Read your data (GET)

Fetch aggregated events or recent errors. Useful for your own dashboards or alerts.

GET http://localhost:3000/api/events?days=7&type=pageview
X-API-Key: YOUR_API_KEY

GET http://localhost:3000/api/errors?days=7&limit=50&resolved=false
X-API-Key: YOUR_API_KEY

9. Connect Cursor or Claude Code (MCP)

Let your AI editor ask LyticData directly what is breaking in production, where in your code, and which of your users hit it. Read-only: it can see errors and fixes, never change anything. Uses your secret read key, not the snippet key. The ready-to-copy versions with your key filled in are in Settings.

Claude Code

claude mcp add --transport http lyticdata http://localhost:3000/api/mcp \
  --header "Authorization: Bearer YOUR_READ_KEY"

Cursor (.cursor/mcp.json)

{
  "mcpServers": {
    "lyticdata": {
      "url": "http://localhost:3000/api/mcp",
      "headers": { "Authorization": "Bearer YOUR_READ_KEY" }
    }
  }
}

Three tools

  • list_errors — open errors, ranked by how many people they hit.
  • get_error_context — stack, the real source line and surrounding code, when and where it happens, and any fix already written.
  • who_hit_it — which of your users hit it (your own user ids), their plan and where they came from.

Then ask: “What errors are my users hitting? Fix the top one.”