Docsllms.txtSign inGo to your sites

Updated

View as Markdown

Quickstart

twelvebit is web analytics with revenue attribution. A small script counts visits. Your payment provider sends payments. twelvebit joins the two, so you see which sources bring money, not only traffic.

You can set it up in three ways. Pick one.

1. Let your coding agent do it

Copy the setup prompt from the home page or from your site in the dashboard, and paste it into Claude Code, Codex or Cursor. The prompt holds no key. The agent runs the CLI below, you approve the sign-in in the browser, and the CLI saves a site key in .env. Then the agent adds the script, tracks the actions that matter, writes analytics.yaml, connects the MCP server and checks that events arrive.

Prompt for your coding agent · holds no key
Set up twelvebit analytics in this project. Before you do anything else, tell me: "A browser tab opens in a few seconds. Approve the connection there. One approval is enough." 1. Run this first, from the project root, before you read the rest of the project or the guide: npx -y twelvebit@latest init <production domain> (Ask me for the production domain if you cannot find it at once in package.json, the README or the deploy config. Do not use localhost.) It prints a link and a code and opens the browser. I approve it once. The sign-in is then saved on this computer, and every later command uses it: do not start another sign-in. The command waits for me (up to 10 minutes), so give it a long timeout or run it in the background. If it stops before I approve, run the same command again: it continues with the same code and does not open a new tab. It saves the site key in .env by itself: do not print the key or put it in chat. It also writes analytics.yaml and a twelvebit section in AGENTS.md. 2. Follow the twelvebit section in AGENTS.md: add the script tag that init printed to the shared layout, track the 3 to 8 actions that matter, and describe them in analytics.yaml. 3. Run npx -y twelvebit@latest codegen, then npx -y twelvebit@latest check --strict. 4. Verify on production only. twelvebit does not track local development, by design: the script ignores localhost and 127.0.0.1, and the server accepts events only from the production domain and its subdomains. Do not start a local copy, add data-allow-localhost or set up local tracking, unless I ask for it. Deploy the change to the production domain (or tell me what to deploy and wait for me), then run npx -y twelvebit@latest status until it shows the first event from the production domain. 5. Optional, at the end: connect the MCP server so that you can read the data later. Claude Code: npx -y twelvebit@latest mcp claude --run (it uses the site key in .env: no new approval). Other agents: MCP server (streamable HTTP, OAuth sign-in): https://twelvebit.app/api/mcp. This opens a second, separate approval page in the browser, so ask me before you run it. Full guide, if you need more: https://twelvebit.app/setup.md. At the end, tell me whether the first event from the production domain has arrived (that is when the setup is complete), and list the events you added and where.

Or start from the terminal in your project folder:

Shell
npx -y twelvebit@latest init example.com

The CLI signs you in through the browser, finds or creates the site, saves a site key in .env (only when .env is in .gitignore), writes a starter analytics.yaml, adds a twelvebit section to AGENTS.md and prints the script tag for your framework. Then tell your agent: "Instrument this app with twelvebit (see AGENTS.md)".

2. Add the script yourself

Put this tag in the <head> of every page:

HTML
<script defer data-website-id="tb_YOUR_SITE_ID" data-domain="example.com" src="https://twelvebit.app/js/script.js"></script>
  • data-website-id is the public id of your site. It is safe to publish.
  • data-domain is your root domain. Subdomains share one visitor id.

See Install for Next.js, React, Vue, Svelte, Astro, Remix, Gatsby, WordPress, Shopify, Webflow, Framer and Google Tag Manager.

3. Check that it works

Deploy the change, then open your site on its production domain in a normal browser window. The dashboard shows the visit within a few seconds. Local development (localhost, 127.0.0.1) is not tracked, by design, so check on production. From a terminal:

Shell
curl -sS https://twelvebit.app/api/v1/install-check -H "Authorization: Bearer $TWELVEBIT_API_KEY"

The response lists the first event time, the last events, counts per type for the last 24 hours, the hosts seen, which planned events have arrived, and next steps when something looks wrong. If nothing arrives, read Troubleshooting.

Next steps

  • Goals: count signups, checkouts and other actions.
  • Revenue: connect Stripe, Polar, Lemon Squeezy, Paddle or Dodo Payments, and pass the visitor id to the checkout.
  • Identify: link a visitor to a user in your app.
  • Tracking plan: keep your events in analytics.yaml and check them in CI.

All pages

PageWhat it covers
InstallThe script tag for every common framework and site builder
Agent setupThe workflow for coding agents, with guardrails
Script referenceEvery data-* attribute, cookies and the JS API
GoalsCustom events from JS, HTML attributes and your server
IdentifyLink visitors to users
RevenueRevenue attribution per payment provider
Tracking planThe analytics.yaml format, codegen and drift checks
API referenceThe REST API at /api/v1
MCPAsk your agent about your analytics
CLItwelvebit init, push, check, codegen and more
Privacy and cookielessWhat is stored, cookieless mode, excluding yourself
ProxyServe the script from your own domain
Bot trackingCount AI crawlers and search bots on your server
TroubleshootingWhen events do not arrive

Agents can read every page as Markdown: add .md to the URL (for example /docs/revenue.md), or read the full guide at /setup.md and the index at /llms.txt.