Skip to main content
Glama
thichcode

Matomo MCP Server

by thichcode

matomo_add_goal

Add and configure a new goal for a Matomo site by specifying the site ID, name, description, match attribute, pattern, and pattern type to track specific user interactions.

Instructions

Thêm một goal mới cho site

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYesMô tả của goal
matchAttributeYesThuộc tính khớp (url, title, event, etc.)
nameYesTên của goal
patternYesMẫu khớp
patternTypeYesLoại mẫu (exact, contains, regex, etc.)
siteIdYesID của site

Implementation Reference

  • Input schema definition for the matomo_add_goal tool, specifying parameters like siteId, name, description, matchAttribute, pattern, and patternType.
    inputSchema: { type: 'object', properties: { siteId: { type: 'number', description: 'ID của site', }, name: { type: 'string', description: 'Tên của goal', }, description: { type: 'string', description: 'Mô tả của goal', }, matchAttribute: { type: 'string', description: 'Thuộc tính khớp (url, title, event, etc.)', }, pattern: { type: 'string', description: 'Mẫu khớp', }, patternType: { type: 'string', description: 'Loại mẫu (exact, contains, regex, etc.)', }, }, required: ['siteId', 'name', 'description', 'matchAttribute', 'pattern', 'patternType'],
  • src/index.ts:274-282 (registration)
    Registration of the matomo_add_goal handler in the switch statement of the CallToolRequestSchema handler.
    case 'matomo_add_goal': return await this.handleAddGoal(args as { siteId: number; name: string; description: string; matchAttribute: string; pattern: string; patternType: string; });
  • MCP tool handler for matomo_add_goal, validates connection and delegates to MatomoApiService.addGoal.
    private async handleAddGoal(args: { siteId: number; name: string; description: string; matchAttribute: string; pattern: string; patternType: string; }) { if (!this.matomoService) { throw new Error('Chưa kết nối đến Matomo. Vui lòng sử dụng matomo_connect trước.'); } const goalId = await this.matomoService.addGoal( args.siteId, args.name, args.description, args.matchAttribute, args.pattern, args.patternType ); return { content: [ { type: 'text', text: `Đã thêm goal thành công với ID: ${goalId}`, }, ], }; }
  • Core helper function in MatomoApiService that makes the actual API request to Goals.addGoal endpoint.
    async addGoal(siteId: number, name: string, description: string, matchAttribute: string, pattern: string, patternType: string): Promise<number> { const response = await this.makeRequest('Goals.addGoal', { idSite: siteId, name, description, matchAttribute, pattern, patternType, }); return response.value; }
  • src/index.ts:151-184 (registration)
    Tool registration in the ListToolsRequestSchema response, including name, description, and schema.
    { name: 'matomo_add_goal', description: 'Thêm một goal mới cho site', inputSchema: { type: 'object', properties: { siteId: { type: 'number', description: 'ID của site', }, name: { type: 'string', description: 'Tên của goal', }, description: { type: 'string', description: 'Mô tả của goal', }, matchAttribute: { type: 'string', description: 'Thuộc tính khớp (url, title, event, etc.)', }, pattern: { type: 'string', description: 'Mẫu khớp', }, patternType: { type: 'string', description: 'Loại mẫu (exact, contains, regex, etc.)', }, }, required: ['siteId', 'name', 'description', 'matchAttribute', 'pattern', 'patternType'], }, },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/thichcode/matomo_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server