Self-hosting

Connect Claude Code to your analytics in one command

Ownlytics team · · 6 min read

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.

Which post made the most money last month?
ownlytics · get_breakdown
“Setup guide” brought in $245 from 1,800 visitors, about $0.14 per visitor. “Launch recap” had the most traffic but earned $49.
PostVisitorsRevenue
Setup guide1,800$245
Pricing compared640$147
Launch recap3,200$49

Fig.Your AI assistant reading your analytics through MCP, read-only. Sample data, not a real site.

What you need first

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:

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.

ScopeUse it when
User (--scope user)You want analytics available in every project
A single projectOnly one repo should see it
Shared with a teamDo 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:

  1. "Which referrer made me the most money this month?"
  2. "Compare this week with last week. What changed, and why?"
  3. "Show my last 10 sales and where each buyer came from."
  4. "Walk me through the journey of my latest customer."
  5. "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.

Is traffic from ChatGPT turning into sales?
ownlytics · get_breakdown
Yes, a little: ChatGPT sent 1,411 visitors and 4 sales ($196). Perplexity sent fewer visitors but one in 310 bought.
SourceVisitorsRevenue
chatgpt.com1,411$196
perplexity.ai620$98
claude.ai388$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:

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

StepWhat you do
1Create a read-only key in Settings, API keys and AI agents
2Run claude mcp add --transport http --scope user ownlytics ...
3Start Claude Code and ask a narrow question
4Check the first answer against your dashboard
Tools available14, all read-only
Key storageHashed 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.

See the live demo · View pricing

Keep reading