# Pegada > Cookie-free web analytics with custom events, a server SDK, an MCP server for AI assistants and a feedback inbox (widget with conversations, email per site). No cookies, no stored IPs (visitor = hash of a per-site salt + IP + user agent), data expires after 13 months. Free during the beta. The product and its UI are in Portuguese (Brazil) and English. Docs for people: https://pegada.dev/docs (Portuguese) and https://pegada.dev/developers (English). Features overview: https://pegada.dev/recursos and https://pegada.dev/features. This file has what an AI assistant needs to install Pegada in a project and to read the data. ## Install in a project The user creates an account at https://pegada.dev/entrar and a site with its domain. Ask the user for the site id (Settings in the dashboard) if you do not have it. The dashboard also has a "Copy instructions" button per site with the id filled in. 1. Visits script: add to the `` of every page (root layout if there is one). It counts page views, including SPA route changes. No cookies, no browser storage, no consent banner needed. Only domains registered for the site are accepted. ```html ``` 2. Browser events (optional): `window.pegada?.track("signup_completed", { plan: "pro", value: 49 })`. - Name: letters, digits and `_ . : -`, up to 50 chars. Prefer past-tense snake_case. Use the language the project already uses for names. - Props: up to 20; key with letters, digits and `_` (up to 40); value string (up to 200), number or boolean. - Never put personal data (email, name, phone, document numbers) in props. - Propose the product's key moments (sign-up, purchase, main features) and instrument them. 3. Server events (optional): npm package `pegada` (no dependencies; Node 18+, Bun, Deno, Workers, Lambda). The server key (`pgd_sk_...`) goes in the `PEGADA_KEY` environment variable; never write it in code or send it to the browser. The user creates it in the site's Settings. ```ts import { createPegada } from "pegada"; const pegada = createPegada({ key: process.env.PEGADA_KEY }); await pegada.track("payment_confirmed", { plan: "pro" }, { ip, userAgent }); ``` - `ip` and `userAgent` are the end user's (from the request); they link the event to the visit and are not stored. - Webhooks (Stripe etc.): in the browser `const visit = await window.pegada.visit()`, store it with the order (e.g. checkout metadata), then send `{ visit }` as the context in the webhook. Valid for 30 days. - Optional context: `path`, `at` (Date or ISO, up to 24 h ago), `country` (ISO 2 letters). Batches: `pegada.trackMany([{ name, props, context }])`, up to 50. - The SDK never throws and times out after 2 s. - Other languages: `POST https://pegada.dev/api/track` with `Authorization: Bearer ` and JSON `{ "name", "props", "ip", "userAgent", "visit" }` (or `{ "events": [...] }`). 4. Feedback widget (optional): a ready "Feedback" button that becomes a conversation after sending (the sender sees the owner's reply and can answer). Stores only the conversation token in localStorage, after sending. ```html ``` - `data-color="#hex"` (use the brand color), `data-lang="pt|en|es|ja"`, `data-position="left"`, `data-button="false"` with `data-trigger="#selector"` or `window.pegadaFeedback.open()`, `data-chat="false"` (no conversation, nothing stored), `data-email="..."` (email already filled in for signed-in users; can be set on the script element after it loads). - If the site already has a "Help", "Contact" or "Feedback" link, prefer `data-button="false"` plus `data-trigger` on it. New replies then mark those elements with the `data-pegada-unread` attribute (style it) and fire a `pegada:feedback` event on window (`detail.unread`). - App state that helps to reproduce problems (plan, screen, ids; never personal data): `window.pegadaFeedback = Object.assign(window.pegadaFeedback || {}, { context: () => ({ plan, screen }) })`. Sent with each submission as `plan=pro ยท screen=/x`. - Own form: `await window.pegada.feedback(message, { kind: "problema" | "ideia" | "outro", email, image })` (needs p.js). - From the server: `POST https://pegada.dev/api/f` with the server key and `{ kind, message, contact }`. - AI agents that use the project can send feedback through the site's public MCP server, no sign-in: `https://pegada.dev/api/mcp/f/SITE_ID` (tool `send_feedback`). Mention it in the project's own llms.txt or API docs if they exist. ## Read the data (MCP) - MCP server (HTTP): `https://pegada.dev/api/mcp`. Signs in with OAuth (the user approves in Pegada). Claude Code: `claude mcp add --transport http pegada https://pegada.dev/api/mcp`. - Without OAuth: a token from Account in the dashboard, sent as `Authorization: Bearer pgd_tk_...`. Read tokens only read; read-and-write tokens also change funnels and reply to feedback. Sites, keys and tokens only change in the dashboard. - Start with `list_sites` and `list_events`, then `get_stats` for the overview and `query_events` for specific questions (counts, breakdowns by prop, filters, sums and averages). Also `funnel`, `retention`, `recent_events`, saved funnels, and the feedback inbox (`list_feedback`, `get_feedback`, `reply_feedback`; show the reply to the user before sending it). - If Pegada could not answer something, send it with `send_feedback`: the people who make Pegada read and reply (`my_feedback`). ## Site email Each site has an address like `name@inbox.pegada.dev`; mail to it becomes feedback and replies thread back into the conversation. The owner can also reply from an address on their own domain (DKIM records plus a TXT proof). A domain with no MX can receive directly in Pegada (one extra MX record), which works as a contact form; a domain that already has email forwards the address instead. Never change an existing MX record. ## Limits 10,000 accepted events per site per day by default (support can raise it). Data expires after 13 months. Bots and automated browsers are not counted. Feedback: 10 per visitor and 300 per site per hour. ## Contact support@pegada.dev (or suporte@pegada.dev)