Metric Breakdown
rybbit_get_metricAnalyze website metrics by dimension to track performance across pages, traffic sources, user devices, and geographic locations.
Instructions
Get metric breakdown by dimension. Use parameter='pathname' for top pages, 'browser'/'operating_system'/'device_type' for tech stats, 'country'/'city' for geo, 'utm_source'/'utm_campaign' for marketing, 'referrer'/'channel' for traffic sources, 'entry_page'/'exit_page' for user flow. Returns sorted list with counts, percentages, bounce rate, and session duration.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| siteId | Yes | Site ID (numeric ID or domain identifier) | |
| startDate | No | Start date in ISO format (YYYY-MM-DD) | |
| endDate | No | End date in ISO format (YYYY-MM-DD) | |
| timeZone | No | IANA timezone (e.g., Europe/Prague). Default: UTC | |
| filters | No | Array of filters. Example: [{parameter:'browser',type:'equals',value:['Chrome']},{parameter:'country',type:'equals',value:['US','DE']}] | |
| pastMinutesStart | No | Alternative to dates: minutes ago start (e.g., 60 = last hour) | |
| pastMinutesEnd | No | Alternative to dates: minutes ago end (default 0 = now) | |
| parameter | Yes | Metric dimension to break down by | |
| page | No | Page number, 1-indexed (default: 1) | |
| limit | No | Results per page (default: 20-50 depending on endpoint, max 200) |
Implementation Reference
- src/tools/metrics.ts:47-85 (handler)The handler function for the rybbit_get_metric tool, which constructs analytics parameters and fetches metric data from the Rybbit client.
async (args) => { try { const { siteId, parameter, page, limit, ...rest } = args as { siteId: string; parameter: z.infer<typeof metricParameterSchema>; page?: number; limit?: number; startDate?: string; endDate?: string; timeZone?: string; filters?: Array<{ parameter: string; type: string; value: (string | number)[] }>; pastMinutesStart?: number; pastMinutesEnd?: number; }; const params = client.buildAnalyticsParams({ ...rest, page, limit }); params.parameter = parameter; const data = await client.get<MetricEntry[]>( `/sites/${siteId}/metric`, params ); return { content: [ { type: "text" as const, text: truncateResponse(data), }, ], }; } catch (err) { const message = err instanceof Error ? err.message : String(err); return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true, }; } } - src/tools/metrics.ts:29-46 (registration)The registration of the rybbit_get_metric tool, including its schema and metadata definition.
server.registerTool( "rybbit_get_metric", { title: "Metric Breakdown", description: "Get metric breakdown by dimension. Use parameter='pathname' for top pages, 'browser'/'operating_system'/'device_type' for tech stats, 'country'/'city' for geo, 'utm_source'/'utm_campaign' for marketing, 'referrer'/'channel' for traffic sources, 'entry_page'/'exit_page' for user flow. Returns sorted list with counts, percentages, bounce rate, and session duration.", annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true, destructiveHint: false, }, inputSchema: { ...analyticsInputSchema, parameter: metricParameterSchema, ...paginationSchema, }, },