Connect Claude Code to your analytics in one command
To connect Claude Code to your Ownlytics analytics, create a read-only API key in your dashboard and run one claude mcp add command with that key in an Authorization header. After that, you can ask Claude Code about traffic, sales and buyer journeys from any project folder.
| Post | Visitors | Revenue |
|---|---|---|
| Setup guide | 1,800 | $245 |
| Pricing compared | 640 | $147 |
| Launch recap | 3,200 | $49 |
Fig.Your AI assistant reading your analytics through MCP, read-only. Sample data, not a real site.
What you need first
- An Ownlytics install, self-hosted or Hosted, with at least one site tracked.
- Claude Code installed on your machine.
- A read-only API key. Create it in the dashboard under Settings, then API keys and AI agents. That page shows the snippets with your URL and key already filled in.
Our docs also say the setup flow updates your install if it is older than version 1.1.0, so run the update first if the MCP option is missing.
The command
Replace the URL with your own dashboard address and the key with the one you created:
claude mcp add --transport http --scope user ownlytics https://YOUR-OWNLYTICS-URL/mcp \
--header "Authorization: Bearer dbk_YOUR_KEY"
What each part does:
--transport httpconnects over Streamable HTTP, which is what the server speaks.--scope usermakes the connection available in every project on your machine.--headercarries your read-only key.
If you prefer a guided path, our docs describe running npx ownlytics@latest mcp, which checks the key works and prints the exact config for other clients too. The full client list is in the MCP docs, and there is a Claude Code specific page at /mcp/claude-code.
Which scope should you pick?
Claude Code lets you choose where the connection is stored. Check Claude Code's own documentation for the current option names, since they belong to that tool.
| Scope | Use it when |
|---|---|
User (--scope user) | You want analytics available in every project |
| A single project | Only one repo should see it |
| Shared with a team | Do not do this with a key in the file |
The last row matters. If a connection config lives in a repository, the key can end up in version control. Keep keys in your user-level setup and never commit them. A read-only key limits damage, but it still reveals your traffic and revenue.
First prompts to try
Start narrow, then widen. These are the kinds of questions our docs suggest:
- "Which referrer made me the most money this month?"
- "Compare this week with last week. What changed, and why?"
- "Show my last 10 sales and where each buyer came from."
- "Walk me through the journey of my latest customer."
- "Which landing page converts best for visitors from Google?"
Each one maps to a read-only tool: a breakdown, a period comparison, a sales list, a visitor journey. Claude Code chooses the tool, calls it, and explains the result. If you are curious how a question becomes a tool call, ask it to tell you which tool it used.
Example (made-up numbers for illustration)
Suppose you ask: "What changed compared with last week?" A reply might look like this. The numbers are invented.
Revenue is up from $180 to $260. Visitors are flat at about 2,100. Conversion rose because of one referrer that sent 90 visitors and 3 sales. Without that referrer, revenue would be roughly unchanged.
The valuable line is the last one. A raw "revenue up 44%" invites a victory lap. The breakdown shows that one source drove the whole change, which is a different decision. You can follow up with "show me those three sales" to see the buyers' paths. For the weekly habit around this, see a weekly analytics review routine for solo founders.
| Source | Visitors | Revenue |
|---|---|---|
| chatgpt.com | 1,411 | $196 |
| perplexity.ai | 620 | $98 |
| claude.ai | 388 | $49 |
Fig.AI assistants as their own channel in the source table. Sample data, not a real site.
Troubleshooting
Our docs have a page of fixes, but the common patterns are:
- Claude Code does not list the server. Run
claude mcp listto see what is registered, and check the URL ends with/mcp. - Authorization errors. Check the key has the
dbk_prefix, that the header readsBearerfollowed by a space and the key, and that the key has not been revoked. - Empty answers. Confirm the site actually has data for the period you asked about. Ask for
7dor30dexplicitly. - Old install. Update with
npx ownlytics@latest update, then try again. - Wrong site. Tools accept a site by domain. If you track several, name the domain in your question.
If you are on Hosted and something fails, email us. Fixes for connection errors are also on the Claude Code page, and self-hosted install problems have their own troubleshooting page in the docs.
When this is not the right tool
If you rarely open Claude Code, this adds nothing the dashboard does not. If you need a figure for an invoice, a tax filing or a public claim, confirm it in the dashboard, because an agent's summary can drop a detail. And if you share your machine or screen often, remember the key lives in your Claude Code config.
For the bigger picture on how agents read your data, including what a read-only key does and does not protect, see AI agents reading your analytics: MCP explained.
At a glance
| Step | What you do |
|---|---|
| 1 | Create a read-only key in Settings, API keys and AI agents |
| 2 | Run claude mcp add --transport http --scope user ownlytics ... |
| 3 | Start Claude Code and ask a narrow question |
| 4 | Check the first answer against your dashboard |
| Tools available | 14, all read-only |
| Key storage | Hashed on the server; revocable any time |
When you want to see the numbers your agent would read, the live demo shows a sample dashboard.
FAQ
How do I connect Claude Code to Ownlytics?
Create a read-only API key in your dashboard, then run claude mcp add --transport http --scope user ownlytics https://YOUR-OWNLYTICS-URL/mcp --header "Authorization: Bearer dbk_YOUR_KEY". Replace the URL and key with yours.
Can Claude Code change my data?
No. The tools are read-only and so is the key. It can read analytics but cannot edit or delete anything through this server.
Does it work on Hosted as well as self-hosted?
Yes. Our docs say the MCP server, CLI data commands and API keys work the same on both. Point them at your dashboard's address.
What should I ask first?
Something narrow and checkable, such as your last five sales and where each buyer came from. Compare the answer with your dashboard once to see how the agent reads your data.