analytics
Fathom Analytics Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Fathom Analytics KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.fathom.*.
Use lua_read_doc("integrations.fathom") inside KosmoKrator to discover the same reference at runtime.
Call Lua from the Headless CLI
Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic
Fathom Analytics workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.fathom.get_account({}))' --json kosmo integrations:lua --eval 'print(docs.read("fathom"))' --json
kosmo integrations:lua --eval 'print(docs.read("fathom.get_account"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local fathom = app.integrations.fathom
local result = fathom.get_account({})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.fathom, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.fathom.default.* or app.integrations.fathom.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Fathom Analytics, use the narrower mcp:lua command.
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json Agent-Facing Lua Docs
This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.
Fathom Analytics - Lua API Reference
Namespace: app.integrations.fathom
Use this integration to manage Fathom sites, events, milestones, account details, aggregation reports, and current visitor counts. The integration follows the documented Fathom API v1 paths and returns the API’s JSON response objects with only request parameter normalization applied.
Account
get_account
Get the authenticated Fathom account profile from /account.
local account = app.integrations.fathom.get_account({})
print(account.name .. " <" .. account.email .. ">")
get_current_user
Backward-compatible alias for account profile lookup. It also calls /account; prefer get_account in new workflows.
Sites
list_sites
List sites in cursor order.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Number of sites, clamped to 1-100. Default: 10. |
starting_after | string | no | Cursor object ID for forward pagination. |
ending_before | string | no | Cursor object ID for reverse pagination. |
local result = app.integrations.fathom.list_sites({limit = 10})
for _, site in ipairs(result.data or {}) do
print(site.id .. ": " .. site.name)
end
get_site
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID, such as ABCDEF. |
create_site / update_site
create_site requires name. update_site requires site_id and accepts the same editable site settings.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
site_id | string | update only | Fathom site ID. |
name | string | create yes, update no | Site display name. |
sharing | string | no | none, private, or public. |
share_password | string | no | Required by Fathom when sharing is private. |
local site = app.integrations.fathom.create_site({
name = "Example Site",
sharing = "none"
})
wipe_site / delete_site
Both require site_id. wipe_site deletes analytics data but keeps the site; delete_site removes the site.
Events
Events are scoped to a site and use Fathom’s nested /sites/{site_id}/events endpoints.
list_events
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID. |
limit | integer | no | Number of events, clamped to 1-100. |
starting_after | string | no | Cursor object ID for forward pagination. |
ending_before | string | no | Cursor object ID for reverse pagination. |
get_event / create_event / update_event / wipe_event / delete_event
get_event, update_event, wipe_event, and delete_event require site_id and event_id. create_event requires site_id and name.
local event = app.integrations.fathom.create_event({
site_id = "ABCDEF",
name = "Signup"
})
Milestones
Milestones are site-scoped annotations. The integration exposes list, get, create, update, and delete.
Common parameters:
| Name | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID. |
milestone_id | string | get/update/delete | Fathom milestone ID. |
name | string | create yes, update no | Milestone name. |
milestone_date | string | create yes, update optional | Milestone date in YYYY-MM-DD format. |
local milestone = app.integrations.fathom.create_milestone({
site_id = "ABCDEF",
name = "Launch day",
milestone_date = "2026-01-15"
})
Reports
get_aggregate
Generate an aggregation report using /aggregations. This helper defaults to entity = "pageview" and sends the provided site_id as entity_id.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID used as entity_id. |
date_from | string | no | Start date or timestamp. |
date_to | string | no | End date or timestamp. |
metrics | string | no | Comma-separated Fathom aggregate names. Default: pageviews,visits,uniques,bounce_rate. |
group_by | string | no | Sent as Fathom field_grouping, such as pathname or country_code. |
sort_by | string | no | Sort expression accepted by Fathom. |
limit | integer | no | Maximum grouped rows. |
date_grouping | string | no | Date grouping accepted by Fathom, such as day or month. |
timezone | string | no | IANA timezone for date grouping. |
filters | string | no | JSON encoded Fathom filter array. |
local top_pages = app.integrations.fathom.get_aggregate({
site_id = "ABCDEF",
date_from = "2026-01-01",
date_to = "2026-01-31",
metrics = "pageviews,visits,uniques",
group_by = "pathname",
sort_by = "pageviews:desc",
limit = 10
})
get_current_visitors
Get current visitor counts for a site from /current_visitors.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID. |
detailed | boolean | no | Include detailed current visitor breakdown when supported. |
local current = app.integrations.fathom.get_current_visitors({
site_id = "ABCDEF",
detailed = true
})
Multi-Account Usage
If you have multiple Fathom accounts configured, use account-specific namespaces:
app.integrations.fathom.list_sites({})
app.integrations.fathom.default.list_sites({})
app.integrations.fathom.work.list_sites({})
The functions are identical across accounts; only credentials differ.
Raw agent markdown
# Fathom Analytics - Lua API Reference
Namespace: `app.integrations.fathom`
Use this integration to manage Fathom sites, events, milestones, account details, aggregation reports, and current visitor counts. The integration follows the documented Fathom API v1 paths and returns the API's JSON response objects with only request parameter normalization applied.
## Account
### get_account
Get the authenticated Fathom account profile from `/account`.
```lua
local account = app.integrations.fathom.get_account({})
print(account.name .. " <" .. account.email .. ">")
```
### get_current_user
Backward-compatible alias for account profile lookup. It also calls `/account`; prefer `get_account` in new workflows.
## Sites
### list_sites
List sites in cursor order.
Parameters:
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Number of sites, clamped to 1-100. Default: 10. |
| `starting_after` | string | no | Cursor object ID for forward pagination. |
| `ending_before` | string | no | Cursor object ID for reverse pagination. |
```lua
local result = app.integrations.fathom.list_sites({limit = 10})
for _, site in ipairs(result.data or {}) do
print(site.id .. ": " .. site.name)
end
```
### get_site
Parameters:
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `site_id` | string | yes | Fathom site ID, such as `ABCDEF`. |
### create_site / update_site
`create_site` requires `name`. `update_site` requires `site_id` and accepts the same editable site settings.
Parameters:
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `site_id` | string | update only | Fathom site ID. |
| `name` | string | create yes, update no | Site display name. |
| `sharing` | string | no | `none`, `private`, or `public`. |
| `share_password` | string | no | Required by Fathom when sharing is private. |
```lua
local site = app.integrations.fathom.create_site({
name = "Example Site",
sharing = "none"
})
```
### wipe_site / delete_site
Both require `site_id`. `wipe_site` deletes analytics data but keeps the site; `delete_site` removes the site.
## Events
Events are scoped to a site and use Fathom's nested `/sites/{site_id}/events` endpoints.
### list_events
Parameters:
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `site_id` | string | yes | Fathom site ID. |
| `limit` | integer | no | Number of events, clamped to 1-100. |
| `starting_after` | string | no | Cursor object ID for forward pagination. |
| `ending_before` | string | no | Cursor object ID for reverse pagination. |
### get_event / create_event / update_event / wipe_event / delete_event
`get_event`, `update_event`, `wipe_event`, and `delete_event` require `site_id` and `event_id`. `create_event` requires `site_id` and `name`.
```lua
local event = app.integrations.fathom.create_event({
site_id = "ABCDEF",
name = "Signup"
})
```
## Milestones
Milestones are site-scoped annotations. The integration exposes list, get, create, update, and delete.
Common parameters:
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `site_id` | string | yes | Fathom site ID. |
| `milestone_id` | string | get/update/delete | Fathom milestone ID. |
| `name` | string | create yes, update no | Milestone name. |
| `milestone_date` | string | create yes, update optional | Milestone date in `YYYY-MM-DD` format. |
```lua
local milestone = app.integrations.fathom.create_milestone({
site_id = "ABCDEF",
name = "Launch day",
milestone_date = "2026-01-15"
})
```
## Reports
### get_aggregate
Generate an aggregation report using `/aggregations`. This helper defaults to `entity = "pageview"` and sends the provided `site_id` as `entity_id`.
Parameters:
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `site_id` | string | yes | Fathom site ID used as `entity_id`. |
| `date_from` | string | no | Start date or timestamp. |
| `date_to` | string | no | End date or timestamp. |
| `metrics` | string | no | Comma-separated Fathom aggregate names. Default: `pageviews,visits,uniques,bounce_rate`. |
| `group_by` | string | no | Sent as Fathom `field_grouping`, such as `pathname` or `country_code`. |
| `sort_by` | string | no | Sort expression accepted by Fathom. |
| `limit` | integer | no | Maximum grouped rows. |
| `date_grouping` | string | no | Date grouping accepted by Fathom, such as `day` or `month`. |
| `timezone` | string | no | IANA timezone for date grouping. |
| `filters` | string | no | JSON encoded Fathom filter array. |
```lua
local top_pages = app.integrations.fathom.get_aggregate({
site_id = "ABCDEF",
date_from = "2026-01-01",
date_to = "2026-01-31",
metrics = "pageviews,visits,uniques",
group_by = "pathname",
sort_by = "pageviews:desc",
limit = 10
})
```
### get_current_visitors
Get current visitor counts for a site from `/current_visitors`.
Parameters:
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `site_id` | string | yes | Fathom site ID. |
| `detailed` | boolean | no | Include detailed current visitor breakdown when supported. |
```lua
local current = app.integrations.fathom.get_current_visitors({
site_id = "ABCDEF",
detailed = true
})
```
## Multi-Account Usage
If you have multiple Fathom accounts configured, use account-specific namespaces:
```lua
app.integrations.fathom.list_sites({})
app.integrations.fathom.default.list_sites({})
app.integrations.fathom.work.list_sites({})
```
The functions are identical across accounts; only credentials differ. local result = app.integrations.fathom.get_account({})
print(result) Functions
get_account Read
Get the authenticated Fathom account profile from the documented /account endpoint.
- Lua path
app.integrations.fathom.get_account- Full name
fathom.fathom_get_account
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_current_user Read
Get the authenticated Fathom account profile. This calls the documented /account endpoint.
- Lua path
app.integrations.fathom.get_current_user- Full name
fathom.fathom_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_sites Read
List all websites tracked in Fathom Analytics. Returns site IDs, names, and domains you can query for analytics data.
- Lua path
app.integrations.fathom.list_sites- Full name
fathom.fathom_list_sites
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Maximum number of sites to return (default: 20). |
starting_after | string | no | Cursor for pagination; pass the ID of the last site from a previous response. |
ending_before | string | no | Cursor for pagination; pass the ID of the first site from a previous response. |
get_site Read
Get details for a specific Fathom Analytics site by ID. Returns site name, domain, tracking code, and other configuration.
- Lua path
app.integrations.fathom.get_site- Full name
fathom.fathom_get_site
| Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | The Fathom site ID (e.g., "CDCLS"). |
create_site Write
Create a new Fathom site with a name and optional sharing settings.
- Lua path
app.integrations.fathom.create_site- Full name
fathom.fathom_create_site
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | yes | Website name. |
sharing | string | no | Sharing setting: none, private, or public. |
share_password | string | no | Password required when sharing is private. |
update_site Write
Update a Fathom site name or sharing settings.
- Lua path
app.integrations.fathom.update_site- Full name
fathom.fathom_update_site
| Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID. |
name | string | no | Updated website name. |
sharing | string | no | Sharing setting: none, private, or public. |
share_password | string | no | Password required when sharing is private. |
wipe_site Write
Wipe all pageviews and event completions from a Fathom site. This is destructive.
- Lua path
app.integrations.fathom.wipe_site- Full name
fathom.fathom_wipe_site
| Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID. |
delete_site Write
Delete a Fathom site. This is destructive and cannot be undone.
- Lua path
app.integrations.fathom.delete_site- Full name
fathom.fathom_delete_site
| Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID. |
list_events Read
List custom events tracked in Fathom Analytics for a site. Returns event names, event IDs, and configuration details.
- Lua path
app.integrations.fathom.list_events- Full name
fathom.fathom_list_events
| Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | The Fathom site ID (e.g., "CDCLS"). |
limit | integer | no | Maximum number of events to return (default: 20). |
starting_after | string | no | Cursor for pagination; event ID to start after. |
ending_before | string | no | Cursor for pagination; event ID to end before. |
get_event Read
Get one Fathom event by site ID and event ID.
- Lua path
app.integrations.fathom.get_event- Full name
fathom.fathom_get_event
| Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID. |
event_id | string | yes | Fathom event ID. |
create_event Write
Create a Fathom event for a site.
- Lua path
app.integrations.fathom.create_event- Full name
fathom.fathom_create_event
| Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID. |
name | string | yes | Event name. |
update_event Write
Update a Fathom event name.
- Lua path
app.integrations.fathom.update_event- Full name
fathom.fathom_update_event
| Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID. |
event_id | string | yes | Fathom event ID. |
name | string | no | Updated event name. |
wipe_event Write
Wipe all completion data belonging to a Fathom event. This is destructive.
- Lua path
app.integrations.fathom.wipe_event- Full name
fathom.fathom_wipe_event
| Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID. |
event_id | string | yes | Fathom event ID. |
delete_event Write
Delete a Fathom event. This is destructive and cannot be undone.
- Lua path
app.integrations.fathom.delete_event- Full name
fathom.fathom_delete_event
| Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID. |
event_id | string | yes | Fathom event ID. |
list_milestones Read
List milestones for a Fathom site with cursor pagination.
- Lua path
app.integrations.fathom.list_milestones- Full name
fathom.fathom_list_milestones
| Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID. |
limit | integer | no | Number of milestones to return, 1-100. |
starting_after | string | no | Cursor; milestone ID to start after. |
ending_before | string | no | Cursor; milestone ID to end before. |
get_milestone Read
Get one milestone by site ID and milestone ID.
- Lua path
app.integrations.fathom.get_milestone- Full name
fathom.fathom_get_milestone
| Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID. |
milestone_id | string | yes | Fathom milestone ID. |
create_milestone Write
Create a milestone for a Fathom site.
- Lua path
app.integrations.fathom.create_milestone- Full name
fathom.fathom_create_milestone
| Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID. |
name | string | yes | Milestone name. |
milestone_date | string | yes | Milestone date in YYYY-MM-DD format. |
update_milestone Write
Update a Fathom milestone name or date.
- Lua path
app.integrations.fathom.update_milestone- Full name
fathom.fathom_update_milestone
| Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID. |
milestone_id | string | yes | Fathom milestone ID. |
name | string | no | Updated milestone name. |
milestone_date | string | no | Updated milestone date in YYYY-MM-DD format. |
delete_milestone Write
Delete a Fathom milestone. This is destructive and cannot be undone.
- Lua path
app.integrations.fathom.delete_milestone- Full name
fathom.fathom_delete_milestone
| Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID. |
milestone_id | string | yes | Fathom milestone ID. |
get_aggregation Read
Get aggregated analytics data from Fathom. Supports pageviews, visits, uniques, bounce rate, and more. Can group results by page, country, browser, device type, etc.
- Lua path
app.integrations.fathom.get_aggregation- Full name
fathom.fathom_get_aggregate
| Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | The Fathom site ID (e.g., "CDCLS"). |
date_from | string | no | Start timestamp, e.g. "2025-01-01 00:00:00". |
date_to | string | no | End timestamp, e.g. "2025-01-31 23:59:59". |
metrics | string | no | Comma-separated aggregates. Pageview values: visits, uniques, pageviews, avg_duration, bounce_rate. |
group_by | string | no | Comma-separated field grouping: hostname, pathname, referrer_hostname, country_code, browser, device_type, utm_source, etc. |
sort_by | string | no | Sort field and direction (e.g., "pageviews:desc", "uniques:asc"). |
limit | integer | no | Maximum number of grouped results to return. |
date_grouping | string | no | Optional date grouping: hour, day, month, or year. |
timezone | string | no | TZ database timezone such as UTC or Europe/Brussels. |
filters | string | no | JSON array of Fathom aggregation filters. |
current_visitors Read
Get the current visitor count for a Fathom site, optionally with top pages and referrers.
- Lua path
app.integrations.fathom.current_visitors- Full name
fathom.fathom_get_current_visitors
| Parameter | Type | Required | Description |
|---|---|---|---|
site_id | string | yes | Fathom site ID. |
detailed | boolean | no | When true, include top pages and referrers. |