Skip to main content
Glama
thichcode

Matomo MCP Server

by thichcode

matomo_add_goal

Add a new goal to a Matomo Analytics site by specifying tracking criteria like URL patterns or event attributes to measure conversions and user actions.

Instructions

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

Input Schema

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

Implementation Reference

  • Input schema definition for the matomo_add_goal tool, specifying parameters and validation.
    { 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'], }, },
  • src/index.ts:274-282 (registration)
    Registration of the tool in the switch statement dispatching to the handler method.
    case 'matomo_add_goal': return await this.handleAddGoal(args as { siteId: number; name: string; description: string; matchAttribute: string; pattern: string; patternType: string; });
  • Tool handler function that checks Matomo connection, calls the service to add the goal, and returns success response.
    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 method in MatomoApiService that performs the actual API request to Matomo's 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; }

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