analytics
Plausible Analytics CLI for AI Agents
Use the Plausible Analytics CLI from KosmoKrator to call Plausible Analytics tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.Plausible Analytics CLI Setup
Plausible Analytics can be configured headlessly with `kosmokrator integrations:configure plausible`.
# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash
# Configure and verify this integration.
kosmokrator integrations:configure plausible --set api_key="$PLAUSIBLE_API_KEY" --enable --read allow --write ask --json
kosmokrator integrations:doctor plausible --json
kosmokrator integrations:status --json Credentials
Authentication type: API key api_key. Configure credentials once, then reuse the same stored profile from scripts, coding CLIs, Lua, and MCP.
| Key | Env var | Type | Required | Label |
|---|---|---|---|---|
api_key | PLAUSIBLE_API_KEY | Secret secret | yes | API Key |
url | PLAUSIBLE_URL | URL url | no | Plausible URL |
Command Patterns
The generic command is stable across every integration. The provider shortcut is shorter for humans.
kosmo integrations:call plausible.plausible_query_stats '{"site_id":"example_site_id","metrics":"example_metrics","date_range":"example_date_range","dimensions":"example_dimensions","filters":"example_filters","date_from":"example_date_from","date_to":"example_date_to","order_by":"example_order_by"}' --json kosmo integrations:plausible plausible_query_stats '{"site_id":"example_site_id","metrics":"example_metrics","date_range":"example_date_range","dimensions":"example_dimensions","filters":"example_filters","date_from":"example_date_from","date_to":"example_date_to","order_by":"example_order_by"}' --json Discovery
These commands return structured output for coding agents that need to inspect capabilities before choosing a function.
kosmo integrations:docs plausible --json
kosmo integrations:docs plausible.plausible_query_stats --json
kosmo integrations:schema plausible.plausible_query_stats --json
kosmo integrations:search "Plausible Analytics" --json
kosmo integrations:list --json Automation Contexts
The same configured command surface works in these environments. The command does not change unless the host wrapper, credentials, or permissions change.
CLI Functions
Every function below can be called headlessly. Commands are highlighted, copyable, and scroll horizontally when payloads are long.
plausible.plausible_query_stats
Query website analytics from Plausible. Supports aggregate stats, timeseries, and breakdowns by dimension. Use dimensions to group results (e.g., by country, source, page). Omit dimensions for simple aggregate totals.
read - Parameters
- site_id, metrics, date_range, dimensions, filters, date_from, date_to, order_by, limit
kosmo integrations:call plausible.plausible_query_stats '{"site_id":"example_site_id","metrics":"example_metrics","date_range":"example_date_range","dimensions":"example_dimensions","filters":"example_filters","date_from":"example_date_from","date_to":"example_date_to","order_by":"example_order_by"}' --json kosmo integrations:plausible plausible_query_stats '{"site_id":"example_site_id","metrics":"example_metrics","date_range":"example_date_range","dimensions":"example_dimensions","filters":"example_filters","date_from":"example_date_from","date_to":"example_date_to","order_by":"example_order_by"}' --json plausible.plausible_realtime_visitors
Get the current number of realtime visitors on a website (visitors in the last 5 minutes).
read - Parameters
- site_id
kosmo integrations:call plausible.plausible_realtime_visitors '{"site_id":"example_site_id"}' --json kosmo integrations:plausible plausible_realtime_visitors '{"site_id":"example_site_id"}' --json plausible.plausible_list_sites
List websites tracked in Plausible Analytics. Returns site domains you can query for analytics data.
read - Parameters
- limit, after
kosmo integrations:call plausible.plausible_list_sites '{"limit":1,"after":"example_after"}' --json kosmo integrations:plausible plausible_list_sites '{"limit":1,"after":"example_after"}' --json plausible.plausible_create_site
Register a new website for tracking in Plausible Analytics.
write - Parameters
- domain, timezone
kosmo integrations:call plausible.plausible_create_site '{"domain":"example_domain","timezone":"example_timezone"}' --json kosmo integrations:plausible plausible_create_site '{"domain":"example_domain","timezone":"example_timezone"}' --json plausible.plausible_delete_site
Remove a website from Plausible Analytics tracking. This deletes all associated data.
write - Parameters
- site_id
kosmo integrations:call plausible.plausible_delete_site '{"site_id":"example_site_id"}' --json kosmo integrations:plausible plausible_delete_site '{"site_id":"example_site_id"}' --json plausible.plausible_list_goals
List all goals (conversion tracking) configured for a website in Plausible.
read - Parameters
- site_id
kosmo integrations:call plausible.plausible_list_goals '{"site_id":"example_site_id"}' --json kosmo integrations:plausible plausible_list_goals '{"site_id":"example_site_id"}' --json plausible.plausible_create_goal
Create a conversion goal for a website in Plausible. Goals can track pageviews to specific pages or custom events.
write - Parameters
- site_id, event_name, page_path
kosmo integrations:call plausible.plausible_create_goal '{"site_id":"example_site_id","event_name":"example_event_name","page_path":"example_page_path"}' --json kosmo integrations:plausible plausible_create_goal '{"site_id":"example_site_id","event_name":"example_event_name","page_path":"example_page_path"}' --json plausible.plausible_delete_goal
Delete a conversion goal from a website in Plausible.
write - Parameters
- site_id, goal_id
kosmo integrations:call plausible.plausible_delete_goal '{"site_id":"example_site_id","goal_id":1}' --json kosmo integrations:plausible plausible_delete_goal '{"site_id":"example_site_id","goal_id":1}' --json Function Schemas
Use these parameter tables when building CLI payloads without calling integrations:schema first.
plausible.plausible_query_stats 9 parameters
kosmo integrations:schema plausible.plausible_query_stats --json | Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | The site domain (e.g., "example.com"). |
metrics | array | yes | Metrics to retrieve: visitors, pageviews, visits, bounce_rate, visit_duration, views_per_visit, events, conversion_rate. |
date_range | string | yes | Time period: "7d", "28d", "30d", "month", "3mo", "6mo", "12mo", or "custom" (requires date_from/date_to). |
dimensions | array | no | Dimensions to group by: visit:source, visit:country, visit:city, visit:device, visit:browser, visit:os, event:page, event:name, time:day, time:month, etc. |
filters | string | no | JSON-encoded filter expressions, e.g., [["is", "visit:country", ["NL"]]]. Pass as a JSON string. |
date_from | string | no | Start date (ISO 8601, e.g., "2025-01-01") when date_range is "custom". |
date_to | string | no | End date (ISO 8601, e.g., "2025-01-31") when date_range is "custom". |
order_by | string | no | JSON-encoded order, e.g., [["visitors", "desc"]]. Pass as a JSON string. |
limit | integer | no | Maximum number of results to return. Sent as pagination.limit (default: 10000). |
plausible.plausible_realtime_visitors 1 parameters
kosmo integrations:schema plausible.plausible_realtime_visitors --json | Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | The site domain (e.g., "example.com"). |
plausible.plausible_list_sites 2 parameters
kosmo integrations:schema plausible.plausible_list_sites --json | Parameter | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Maximum number of sites to return (default: 100). |
after | string | no | Cursor for pagination — pass the value from a previous response to get the next page. |
plausible.plausible_create_site 2 parameters
kosmo integrations:schema plausible.plausible_create_site --json | Parameter | Type | Required | Description |
|---|---|---|---|
domain | string | yes | The domain to track (e.g., "example.com"). |
timezone | string | no | Timezone for the site (e.g., "Europe/Amsterdam"). Defaults to "Etc/UTC". |
plausible.plausible_delete_site 1 parameters
kosmo integrations:schema plausible.plausible_delete_site --json | Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | The site domain to delete (e.g., "example.com"). |
plausible.plausible_list_goals 1 parameters
kosmo integrations:schema plausible.plausible_list_goals --json | Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | The site domain (e.g., "example.com"). |
plausible.plausible_create_goal 3 parameters
kosmo integrations:schema plausible.plausible_create_goal --json | Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | The site domain (e.g., "example.com"). |
event_name | string | no | Custom event name to track (e.g., "Signup"). Use this OR page_path, not both. |
page_path | string | no | Page path to track visits to (e.g., "/thank-you"). Use this OR event_name, not both. |
plausible.plausible_delete_goal 2 parameters
kosmo integrations:schema plausible.plausible_delete_goal --json | Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | The site domain (e.g., "example.com"). |
goal_id | integer | yes | The ID of the goal to delete. |
Permissions
Headless calls still follow the integration read/write permission policy. Configure read/write defaults with
integrations:configure. Add --force only for trusted automation that should bypass that policy.