Claude-skill-registry-data matomo-api
Matomo (Piwik) analytics platform API. Use for web analytics, tracking implementation, reporting API integration, plugin development, PHP/JavaScript tracking clients, and database schema understanding.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry-data
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry-data "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/matomo-api" ~/.claude/skills/majiayu000-claude-skill-registry-data-matomo-api && rm -rf "$T"
manifest:
data/matomo-api/SKILL.mdsource content
Matomo API Skill
Comprehensive API reference for Matomo (formerly Piwik), the open-source web analytics platform. Covers tracking APIs, reporting APIs, JavaScript/PHP clients, and database schema.
When to Use This Skill
This skill should be triggered when:
- Implementing Matomo tracking on websites or applications
- Building integrations with Matomo's Reporting API
- Querying analytics data programmatically
- Setting up event tracking, goal conversions, or ecommerce tracking
- Working with Matomo's JavaScript or PHP tracking clients
- Understanding Matomo's database structure for custom queries
- Implementing consent management and privacy controls
- Debugging Matomo tracking issues
Quick Reference
Tracking HTTP API Endpoint
https://your-matomo-domain.example/matomo.php
Required Parameters:
- Website ID being trackedidsite
- Required to enable trackingrec=1
Common Parameters:
- Page title for pageviewsaction_name
- Full URL of the current actionurl
- 16-character hexadecimal visitor ID_id
- Random value to prevent cachingrand
- API versionapiv=1
Event Tracking Parameters
- Event categorye_c
- Event actione_a
- Event namee_n
- Event value (numeric)e_v
Goal Conversion
- Goal ID to trigger conversionidgoal
- Monetary value for conversionrevenue
Ecommerce Parameters
- Order IDec_id
- JSON array of itemsec_items
- Total order valuerevenue
- Subtotalec_st
- Taxec_tx
- Shippingec_sh
- Discountec_dt
Reporting API Endpoint
https://your-matomo-domain.example/index.php?module=API&method=MODULE.METHOD&format=FORMAT
Standard Parameters:
| Parameter | Values | Purpose |
|---|---|---|
| Integer or comma-separated | Website ID(s) |
| day, week, month, year, range | Time period |
| YYYY-MM-DD or magic keywords | Specific date |
| xml, json, csv, tsv, html, rss | Output format |
| Your API token | Authentication |
Date Magic Keywords:
,todayyesterday
,lastWeek
,lastMonthlastYear
(e.g.,lastX
)last7
(e.g.,previousX
)previous30
JavaScript Tracking
// Page view _paq.push(['trackPageView', 'Custom Page Title']); // Event _paq.push(['trackEvent', 'Category', 'Action', 'Name', Value]); // Goal conversion _paq.push(['trackGoal', goalId, customRevenue]); // Site search _paq.push(['trackSiteSearch', 'keyword', 'category', resultsCount]); // Ecommerce order _paq.push(['trackEcommerceOrder', orderId, grandTotal, subTotal, tax, shipping, discount]);
PHP Tracking
use MatomoTracker; $tracker = new MatomoTracker($idSite, 'https://matomo.example.com/'); $tracker->setTokenAuth($token); $tracker->setUserId($userId); $tracker->doTrackPageView('Page Title'); $tracker->doTrackEvent('Category', 'Action', 'Name', $value); $tracker->doTrackGoal($idGoal, $revenue);
Consent Management (JavaScript)
// Require consent before tracking _paq.push(['requireConsent']); // When user gives consent _paq.push(['setConsentGiven']); // Cookie-specific consent _paq.push(['requireCookieConsent']); _paq.push(['rememberCookieConsentGiven', hoursToExpire]); // Opt-out _paq.push(['optUserOut']);
Reference Files
This skill includes comprehensive documentation in
references/:
- tracking-http-api.md - HTTP Tracking API specification
- reporting-api.md - Reporting API methods and parameters
- javascript-client.md - JavaScript Tracking Client reference
- php-client.md - PHP Tracking Client reference
- database-schema.md - Database tables and relationships
Common Patterns
Bulk Tracking (HTTP)
POST https://matomo.example.com/matomo.php { "requests": [ "?idsite=1&rec=1&url=https://example.org/page1", "?idsite=1&rec=1&url=https://example.org/page2" ], "token_auth": "your_token_here" }
Bulk API Requests (Reporting)
?module=API&method=API.getBulkRequest &urls[0]=method%3DVisitsSummary.get%26idSite%3D1%26period%3Dday%26date%3Dtoday &urls[1]=method%3DActions.getPageUrls%26idSite%3D1%26period%3Dday%26date%3Dtoday
Segmentation
# Visits from mobile devices in United States &segment=deviceType==smartphone;countryCode==us # Visits with specific event &segment=eventCategory==Video;eventAction==Play
PHP Bulk Tracking
$tracker->enableBulkTracking(); $tracker->doTrackPageView('Page 1'); $tracker->doTrackPageView('Page 2'); $tracker->doTrackEvent('Category', 'Action'); $tracker->doBulkTrack(); // Send all at once
Key API Modules
Visitor Analytics
- Overall visit metricsVisitsSummary
- Geographic dataUserCountry
- Device and browser infoDevicesDetection
- Language preferencesUserLanguage
Actions & Content
- Pages, downloads, outlinksActions
- Custom event trackingEvents
- Content impression trackingContents
Conversions
- Goal conversions and revenueGoals
- Ecommerce transactionsEcommerce
Traffic Sources
- Traffic source analysisReferrers
- Campaign trackingMarketingCampaignsReporting
Real-time
- Real-time visitor dataLive
- Recent visitor detailsLive.getLastVisitsDetails
Core Metrics
| Metric | Description |
|---|---|
| Unique visitors |
| Total visits (30-min session) |
| Page views, downloads, outlinks |
| Single-page visit percentage |
| Average page duration |
| Goal/ecommerce revenue |
| Goal achievement ratio |
Database Tables
Log Data (Raw)
- Individual visitslog_visit
- Actions within visitslog_link_visit_action
- Action definitions (URLs, titles)log_action
- Goal conversionslog_conversion
- Ecommerce itemslog_conversion_item
Archive Data (Aggregated)
- Numeric metricsarchive_numeric_YYYY_MM
- Report data (compressed)archive_blob_YYYY_MM
Configuration
- Website configurationsite
- Goal definitionsgoal
- Saved segmentssegment
- User accountsuser
- User permissionsaccess
Authentication
Token Authentication
&token_auth=YOUR_TOKEN_HERE
- Create tokens in: Administration > Personal > Security > Auth tokens
- Never share URLs containing tokens publicly
- Use POST requests with token in body for enhanced security
Features Requiring Auth
- IP address override (
)cip - Custom timestamp (
)cdt - Geolocation override (
,country
,region
,city
,lat
)long
Performance Tips
- Use Bulk Tracking - Batch multiple tracking calls
- Cache API Responses - Set appropriate cache headers
- Use Segments Sparingly - Complex segments impact performance
- Archive Data - Query archive tables for historical reports
- Limit Results - Use
to restrict row countsfilter_limit
Resources
- Official API Documentation
- Tracking HTTP API
- Reporting API
- JavaScript Client
- PHP Client
- Database Schema
Notes
- Matomo was formerly known as Piwik
- API supports both Matomo 4.x and 5.x versions
- Session timeout default is 30 minutes
- Visitor ID is 16-character hexadecimal
- All tracking requests should include
parameterrec=1