smartlead_get_campaign_top_level_analytics_by_date
Retrieve campaign analytics including key metrics for a specified date range to track performance and measure email marketing effectiveness.
Instructions
Fetch campaign top level analytics for a specific date range.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| campaign_id | Yes | ID of the campaign to fetch analytics for | |
| end_date | Yes | End date in YYYY-MM-DD format | |
| start_date | Yes | Start date in YYYY-MM-DD format |
Implementation Reference
- src/handlers/statistics.ts:222-265 (handler)Core execution logic for the tool: validates input with isCampaignTopLevelAnalyticsByDateParams, calls Smartlead API /campaigns/{campaign_id}/top-level-analytics-by-date with date range params, returns JSON data or error.async function handleCampaignTopLevelAnalyticsByDate( args: unknown, apiClient: AxiosInstance, withRetry: <T>(operation: () => Promise<T>, context: string) => Promise<T> ) { if (!isCampaignTopLevelAnalyticsByDateParams(args)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid arguments for smartlead_get_campaign_top_level_analytics_by_date' ); } const { campaign_id, start_date, end_date } = args; try { const response = await withRetry( async () => apiClient.get(`/campaigns/${campaign_id}/top-level-analytics-by-date`, { params: { start_date, end_date } }), 'get campaign top level analytics by date' ); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], isError: false, }; } catch (error: any) { return { content: [{ type: 'text', text: `API Error: ${error.response?.data?.message || error.message}` }], isError: true, }; } }
- src/tools/statistics.ts:100-122 (schema)Tool definition including name, description, category (CAMPAIGN_STATISTICS), and input schema specifying required parameters: campaign_id (number), start_date/end_date (strings in YYYY-MM-DD).export const CAMPAIGN_TOP_LEVEL_ANALYTICS_BY_DATE_TOOL: CategoryTool = { name: 'smartlead_get_campaign_top_level_analytics_by_date', description: 'Fetch campaign top level analytics for a specific date range.', category: ToolCategory.CAMPAIGN_STATISTICS, inputSchema: { type: 'object', properties: { campaign_id: { type: 'number', description: 'ID of the campaign to fetch analytics for', }, start_date: { type: 'string', description: 'Start date in YYYY-MM-DD format', }, end_date: { type: 'string', description: 'End date in YYYY-MM-DD format', }, }, required: ['campaign_id', 'start_date', 'end_date'], }, };
- src/index.ts:211-214 (registration)Conditionally registers the statisticsTools array (containing this tool's definition) into the central ToolRegistry instance.// Register campaign statistics tools if enabled if (enabledCategories.campaignStatistics) { toolRegistry.registerMany(statisticsTools); }