Skip to Content

MCP Server

Betterlytics exposes your analytics data through a Model Context Protocol (MCP)  server. This lets you ask AI agents about your website’s traffic in natural language, and connect real analytics data to your UI, UX, and code to make data-driven optimizations directly from your development workflow. No dashboards or manual queries needed.

Creating an API Token

  1. Navigate to Dashboard > Settings > MCP
  2. Enter a name for your token (e.g. “Claude Desktop”)
  3. Choose an expiration: 30, 90, or 180 days (default 90), or no expiry
  4. Click Create token
  5. Copy the token immediately, it is only shown once

Setup

Pick your client below to see only its setup steps. Claude Desktop, Claude Code, Cursor, VS Code, Windsurf, Antigravity and Codex are supported.

Paste it to get ready-to-use snippets and install links. It is substituted in your browser only, never sent to us and never saved.

Run this in your project directory. Add --scope user to make it available across all your projects:

claude mcp add --transport http betterlytics https://betterlytics.io/api/mcp \
  --header "Authorization: Bearer btl_your_token_here"

Replace btl_your_token_here with the token you copied, or paste it above to fill it in for you.

What You Can Ask About

Once connected, your AI assistant has access to your analytics data. You can query it conversationally, or let your agent use it to inform UI, UX, and code changes. Here are some of the things you can explore:

  • Traffic overview: visitors, sessions, and pageviews over any time period
  • Page performance: top pages, specific URL analysis, scroll depth
  • Devices and browsers: desktop vs mobile vs tablet, browser breakdown
  • Geographic distribution: visitor counts by country
  • Traffic sources: where your visitors are coming from (search, social, direct, referrers)
  • UTM campaign tracking: analyze traffic by source, medium, campaign, term, and content
  • Custom events: track and analyze custom events you’ve set up
  • Trends over time: daily or hourly breakdowns to spot patterns
  • Funnels: list saved funnels with step-by-step conversion data, or run ad-hoc funnel analyses with custom steps
  • User journeys: analyze navigation paths through your site, showing page-to-page transitions with traffic volumes
  • Error tracking: list captured errors, inspect stack traces, and see the session trail leading up to each error
  • Uptime monitoring: check whether your monitors are up right now, along with uptime percentage, response times, and SSL certificate status
  • Downtime incidents: list ongoing and resolved outages with their severity, duration, and cause
  • Status pages: see what your public status page shows visitors right now, and spot detected outages that have no posted incident

Example Questions

Here are some questions you can try:

Traffic analysis

  • “Compare my daily visitors this week vs last week. Is traffic trending up or down?”
  • “What percentage of my traffic comes from search vs social vs direct over the last 90 days?”
  • “Which countries had the most visitors this month, and what devices do they use?”

Content performance

  • “Which pages have the highest pageviews but lowest scroll depth? I might need to improve them.”
  • “Show me the top 10 landing pages by sessions, broken down by traffic source.”
  • “What’s the average scroll depth on my blog posts vs my product pages?”

Conversion and events

  • “How many cart-checkout events happened on mobile vs desktop this month?”
  • “What’s my product-clicked to cart-checkout ratio, and is it better on desktop or mobile?”
  • “Show me a daily trend of custom events for the past 28 days, any spikes?”

Campaign attribution

  • “Break down visitors by UTM campaign for Q1. Which campaigns drove the most traffic?”
  • “How did traffic from my spring-sale UTM campaign perform compared to organic search?”

Funnels

  • “How did my funnels perform last month?”
  • “What’s my signup conversion rate? Show me the drop-off at each step.”
  • “Run a funnel from /pricing to /signup to /dashboard. How many visitors make it through?”

User journeys

  • “What are the most common navigation paths on my site?”
  • “Show me user journeys from last month. Where do visitors go after the landing page?”
  • “What pages do visitors explore after viewing the demo?”

Error tracking

  • “What are the most common errors on my site this week?”
  • “Show me the stack trace for the TypeError that’s affecting the most users.”
  • “Where in my code is this error occurring?”
  • “What was the user doing right before this error occurred? Walk me through the session trail.”
  • “Are there any new errors since my last deploy?”

Uptime monitoring

  • “Are all my monitors up right now?”
  • “What outages did we have this week, and how long did each one last?”
  • “What’s the uptime percentage for my API health check over the last 28 days?”
  • “Are any of my SSL certificates expiring soon?”
  • “Which monitor has the slowest response times this month?”

Status pages

  • “What does my status page show visitors right now?”
  • “Is there an ongoing outage that I haven’t posted an incident for?”
  • “Summarize the incidents currently published on my status page and their latest updates.”

Cross-dimensional

  • “What browsers do my mobile visitors from Germany use?”
  • “Show me the hourly traffic pattern for today. When is my peak hour?”
  • “Which referrer sources bring visitors that scroll the deepest on my pages?”

Managing Tokens

View and manage your tokens from Dashboard > Settings > MCP. Each token shows its creation date, when it was last used, and when it expires (or that it never does). You can delete tokens at any time. Deleted tokens are immediately revoked.

Expired tokens stop authenticating and remain in the list so you can spot and delete them. A token’s expiration can’t be changed after creation; to extend access, create a new token.

Security

  • Each token is scoped to a single dashboard
  • Requests are rate-limited to 60 per minute per site

Questions? Join our Discord community  for help!