# GoatCounter MCP

> GoatCounter monitors your web traffic privately. This MCP tracks pageviews, analyzes visitor stats by browser or location, and lets you manage multiple sites directly from any AI agent. Get detailed reports, download CSV data, and track custom events without ever compromising user privacy.

## Overview
- **Category:** productivity
- **Price:** Free
- **Tags:** web-analytics, privacy-focused, traffic-monitoring, visitor-stats, data-export, marketing-insights

## Description

Connect your site analytics to any AI client through Vinkius's catalog. You can now get a full picture of how people interact with your site—all while keeping their data private. Instead of logging into an analytics dashboard and clicking through tabs, you simply ask your agent for what you need. Need to know the total pageviews over the last 30 days? Ask. Want to see which browsers are hitting your checkout page? Ask that too. You can even list all your registered sites or send custom hits directly from your code. It's about getting reliable, actionable data summaries and exporting full datasets right inside your workflow.

## Tools

### count_hits
Send pageviews or custom events to GoatCounter for tracking.

### create_site
Registers a new website into your monitored account.

### download_export
Downloads the final, completed data export file (CSV or JSON).

### get_export
Checks if a requested data export is ready and retrieves its status.

### get_site
Fetches detailed information about a specific registered site.

### list_sites
Returns a list of all websites currently registered under your account.

### get_me
Retrieves basic account details, including your current API key information.

### start_export
Begins the background process to generate a complete data export file, returning an ID for tracking.

### get_stats_hits_path
Gathers specific referral statistics for a single, defined page path.

### get_stats_hits
Provides an overview of pageviews broken down by the URL path.

### get_stats_page_detail
Gets highly detailed statistics for a specific item within a category, such as a particular browser version.

### get_stats_page
Pulls general usage stats, allowing breakdown by broad categories like browser or OS.

### get_stats_total
Calculates the total number of pageviews across your site for a specified date range.

### update_site
Modifies existing settings or configurations for any of your monitored websites.

## Prompt Examples

**Prompt:** 
```
Show me the total pageview counts for the last 30 days.
```

**Response:** 
```
I've retrieved your stats. In the last 30 days, your site received a total of 12,450 pageviews.
```

**Prompt:** 
```
List all the sites registered in my GoatCounter account.
```

**Response:** 
```
You have 3 sites registered: 'Personal Blog' (ID: 101), 'E-commerce Store' (ID: 102), and 'Docs Portal' (ID: 103).
```

**Prompt:** 
```
Get detailed stats for browser versions used by my visitors.
```

**Response:** 
```
Analyzing browser data... Chrome 118 is your most popular version (45%), followed by Firefox 119 (20%) and Safari 17 (15%).
```

## Capabilities

### Get site performance metrics
Retrieves total pageview counts for a specific date range or analyzes traffic volume per content path.

### Break down visitor demographics
Provides detailed stats, grouping visitors by operating system, browser version, location, and language.

### Manage site configurations
Allows you to list all registered sites or create new ones within your GoatCounter account.

### Export raw data for external tools
Initiates and retrieves full CSV or JSON data exports, making the analytics available in other reporting systems.

### Track custom user events
Sends specific hits or events directly from your backend code to supplement standard traffic counts.

## Use Cases

### Debugging a poor conversion rate
A developer notices the checkout page is failing. They ask their agent to use `get_stats_hits_path` for that specific path, immediately identifying if the issue is browser-related by cross-referencing the results with `get_stats_page_detail`. This pinpoints whether Chrome or Safari users are having trouble.

### Generating quarterly board reports
A data analyst needs a full dataset for Q2. They ask their agent to run `start_export`, wait for the status using `get_export`, and then download the final file via `download_export`—all without manual copy-pasting.

### Onboarding a new client site
A product manager needs to monitor a beta site. They use `list_sites` to confirm it's missing and then immediately run `create_site`, getting the new URL added for monitoring without leaving their chat interface.

### Validating backend tracking logic
A developer just deployed a new feature. They ask their agent to manually send a test event using `count_hits` and then query the recent stats, verifying that the custom hit appeared correctly in the analytics summary.

## Benefits

- Get immediate traffic data. Instead of digging through a dashboard, ask for the total pageviews using `get_stats_total` and get an answer instantly.
- Understand your audience deeply. You can break down visitor stats by OS or browser type with `get_stats_page`, helping you target development efforts better.
- Keep data private and usable. The tool lets you initiate exports via `start_export` and download the resulting CSV/JSON file for external use, all without compromising user privacy.
- Manage everything from one place. Use `list_sites` to see every site you own or `create_site` to onboard a new project immediately.
- Track actions where standard analytics fall short. Send custom events using `count_hits` directly from your code, giving you granular insights into user behavior.

## How It Works

The bottom line is you get web analytics insights without leaving your code editor or terminal.

1. Subscribe to this MCP and provide your GoatCounter API Key and instance URL.
2. Direct your AI agent to run a query, like 'Show me the total pageviews for last month.'
3. The agent executes the tool call and returns the summarized data directly in your chat window.

## Frequently Asked Questions

**How do I check total pageviews with get_stats_total?**
You give your agent a date range, and the tool calculates the combined count of all pageviews for that period. This is the fastest way to grasp overall traffic volume.

**What's the difference between list_sites and get_site?**
`list_sites` gives you a master roster of every site connected to your account. `get_site`, however, pulls detailed configuration data for one specific site ID.

**Can I track a custom event using count_hits?**
Yes. You can send hits or events directly from your code using the `count_hits` tool. This is ideal for tracking user actions that don't generate a standard pageview.

**How do I download my data with download_export?**
You must first start the export job via `start_export`. Then, use `get_export` to monitor its status. Once confirmed complete, you call `download_export`.

**How can I verify my API key or check my account details using get_me?**
The `get_me` tool retrieves your current user information, including the necessary API credentials. This confirms you're operating with the correct keys before running any analytics queries.

**If I need to change my site’s domain or settings, which tool should I use? (update_site)**
You must use `update_site` when changing configurations for a registered property. This allows you to adjust tracking parameters or modify the domain without writing code changes.

**How do I know if my background data export job is finished? (start_export and get_export)**
First, run `start_export` to queue your full dataset. Then, use `get_export` to check its status; it will provide the link once the file is ready for download.

**I only want referral data for a specific page path, not overall hits. How do I get that? (get_stats_hits_path)**
Use `get_stats_hits_path` to filter the metrics down to just referral statistics for a single, specified page. This gives you deeper insight than general hit counts.

**Can I see which browsers my visitors are using?**
Yes. Use the `get_stats_page` tool with the 'browsers' category to see a breakdown of visitor browser statistics for your chosen date range.

**How do I export all my analytics data for backup?**
You can start a background export using `start_export`. Once processed, use `get_export` to check the status and `download_export` to retrieve the file.

**Is it possible to track custom events from my server code?**
Absolutely. The `count_hits` tool allows you to send pageviews or custom events directly to GoatCounter from any backend or middleware.