Beschreibung
Pagemetrics for Matomo bringt datenschutzfreundliche, serverseitige Analysen nach WordPress und nutzt dafür die PHP-Bibliothek pagemachine/matomo-tracking. Aktiviert sendet das Plugin Seitenaufrufe und optionale Download-Ereignisse von deiner WordPress-Website direkt an eine Matomo-Instanz, ohne den JavaScript-Tracker von Matomo zu laden.
Wichtigste Vorteile:
- Erfasse Seitenaufrufe serverseitig mit voller Kontrolle über Attribute wie Titel, URL und Referrer.
- Optionales Download-Tracking schreibt Dateilinks um und protokolliert den Klick, bevor Besucher weitergeleitet werden.
- Optional AI assistant bot tracking detects crawls from ChatGPT, Claude, Perplexity and others and forwards them to Matomo’s dedicated AI Assistants report.
- Multisite-fähig – Netzwerk-Admins können Standardwerte definieren, einzelne Websites können sie überschreiben.
- Respektiert Do-Not-Track- und Global-Privacy-Control-Header über die zugrunde liegende Bibliothek.
- Protokolliert Probleme im WordPress-Debug-Log, wenn
WP_DEBUGaktiv ist.
Du brauchst Unterstützung bei Matomo oder serverseitigem Tracking? Pagemachine bietet Beratung, Implementierung und fortlaufenden Support über unsere Pagemetrics-Lösung. Mehr Infos: Pagemetrics.eu
Entwickler-Hooks
Page view tracking:
pm_matomo_tracking_should_track_request— Returnfalseto skip page view tracking for the current request.pm_matomo_tracking_visitor_ip— Override the visitor IP forwarded to Matomo ascip(defaults toREMOTE_ADDR; used for page views and downloads when an auth token is set). Return an empty string to skip IP forwarding.
Download tracking:
pm_matomo_tracking_should_rewrite_downloads— Gibfalsezurück, um die originalen Download-URLs für den aktuellen Beitrag zu behalten.pm_matomo_tracking_is_download_url— Entscheide, ob eine bestimmte URL umgeschrieben werden soll (erhält URL und Standard-Endungsliste).pm_matomo_tracking_download_extensions— Passe die Liste der Dateiendungen an, die als Downloads zählen.pm_matomo_tracking_download_url— Passe die erzeugte Weiterleitungs-URL fürs Download-Tracking an.pm_matomo_tracking_download_redirect_status— Ändere den HTTP-Statuscode, der beim Weiterleiten zur Originaldatei genutzt wird.
AI assistant bot tracking:
pm_matomo_tracking_ai_bot_user_agents— Extend or replace the list of User-Agent substrings used to detect AI bots.
General:
pm_matomo_tracking_log_message— Lausche auf Debug-Meldungen, die ausgegeben werden, solangeWP_DEBUGaktiv ist.
Beispiele
// Skip tracking for administrators.
add_filter('pm_matomo_tracking_should_track_request', static function ($shouldTrack) {
return current_user_can('manage_options') ? false : $shouldTrack;
});
// Keep original download URLs on the privacy policy page.
add_filter('pm_matomo_tracking_should_rewrite_downloads', static function ($shouldRewrite) {
return is_page('privacy-policy') ? false : $shouldRewrite;
});
// Force CDN assets to be treated as downloads.
add_filter('pm_matomo_tracking_is_download_url', static function ($decision, $url) {
return str_contains($url, 'cdn.example.com/assets/') ? true : $decision;
}, 10, 2);
// Add extra file types to download tracking.
add_filter('pm_matomo_tracking_download_extensions', static function ($extensions) {
$extensions = array_merge($extensions, ['svg', 'heic']);
return array_unique($extensions);
});
// Append a checksum to rewritten download URLs.
add_filter('pm_matomo_tracking_download_url', static function ($trackingUrl, $target, $label) {
$checksum = substr(hash('sha256', $target . $label), 0, 12);
return add_query_arg('pm_checksum', $checksum, $trackingUrl);
}, 10, 3);
// Use a 307 redirect instead of the default 302.
add_filter('pm_matomo_tracking_download_redirect_status', static function () {
return 307;
});
// Add a custom bot to AI assistant tracking.
add_filter('pm_matomo_tracking_ai_bot_user_agents', static function (array $substrings): array {
$substrings[] = 'MyCustomBot';
return $substrings;
});
// Behind a reverse proxy: forward the real client IP from X-Forwarded-For.
add_filter('pm_matomo_tracking_visitor_ip', static function ($ip, $request) {
$forwarded = $request->getHeaderLine('X-Forwarded-For');
if ($forwarded === '') {
return $ip;
}
// Use the first (client) address in the list.
return trim(explode(',', $forwarded)[0]);
}, 10, 2);
// Forward debug messages to the PHP error log while developing.
add_action('pm_matomo_tracking_log_message', static function ($level, $message) {
if (!defined('WP_DEBUG') || WP_DEBUG !== true) {
return;
}
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
error_log(sprintf('[Pagemetrics for Matomo][%s] %s', strtoupper((string) $level), $message));
}, 10, 2);
Installation
- Lade das Plugin-Verzeichnis
pagemetrics-for-matomoinklusivevendor/-Ordner in den Ordnerwp-content/pluginsdeiner Website hoch. - Aktiviere das Plugin über Plugins Pagemetrics for Matomo in WordPress.
- Öffne Einstellungen Pagemetrics for Matomo und konfiguriere:
- Matomo-URL (z. B.
https://matomo.example.com/) - Standard-Matomo-Website-ID
- Optionales Auth-Token (erforderlich für IP-Tracking und andere privilegierte Attribute)
- HTTP-Timeout für Matomo-Anfragen
- Schalter für Download-Tracking, falls das Plugin Dateilinks automatisch umschreiben soll
- AI assistant bot tracking toggle, to send AI crawler hits to Matomo’s AI Assistants report (requires Matomo 5.8.0 or later)
- Matomo-URL (z. B.
- (Multisite) Netzwerk-Admins können Standardwerte unter Netzwerkverwaltung Einstellungen Pagemetrics for Matomo festlegen. Einzelne Websites können diese Werte auf ihrer lokalen Einstellungsseite überschreiben.
Das Plugin sendet Daten, sobald Matomo-URL und Website-ID eingetragen sind.
FAQ
-
Nein. Das Auth-Token ist optional. Gib es nur an, wenn du IP-Adressen weitergeben oder Matomo-Parameter nutzen musst, die eine Authentifizierung erfordern. Das Token wird serverseitig gespeichert und nie im Browser gezeigt.
-
How is the visitor IP forwarded behind a proxy or CDN?
-
When an auth token is set, the plugin forwards the visitor IP to Matomo as the
cip parameter, resolved fromREMOTE_ADDRby default. If your site is behind
a reverse proxy or CDN, use thepm_matomo_tracking_visitor_ipfilter to return
the real client IP from your trusted forwarded header. -
Kann ich das Umschreiben von Download-Links deaktivieren?
-
Ja. Lass den Schalter Downloads nachverfolgen in den Einstellungen deaktiviert. Du kannst auch den Filter
pm_matomo_tracking_should_rewrite_downloadsnutzen, um das Umschreiben programmatisch für bestimmte Beiträge oder Dateitypen zu deaktivieren. -
How does AI assistant bot tracking work?
-
When the Track AI assistant bots toggle is enabled, the plugin inspects the
User-Agent header of every front-end request. If it matches a known AI crawler
(ChatGPT, Claude, Perplexity, MistralAI, Gemini, GoogleAgent, NovaAct), a
server-side telemetry hit is sent to Matomo usingrecMode=1. The hit is
recorded in Matomo’s dedicated AI Assistants report and does not count as a
normal visit. Requires Matomo 5.8.0 or later. -
Can I add custom AI bot User-Agents?
-
Yes. Use the
pm_matomo_tracking_ai_bot_user_agentsfilter to extend or replace
the default list of User-Agent substrings:add_filter('pm_matomo_tracking_ai_bot_user_agents', static function (array $substrings): array { $substrings[] = 'MyCustomBot'; return $substrings; }); -
Was passiert, wenn Matomo ausfällt?
-
Anfragen nutzen ein konfigurierbares HTTP-Timeout (Standard drei Sekunden). Wenn Matomo nicht erreichbar ist, wird das Tracking übersprungen und eine Warnung protokolliert (nur wenn WP_DEBUG aktiv ist). Das Rendering läuft normal weiter.
Rezensionen
Zu diesem Plugin liegen noch keine Rezensionen vor.
Mitwirkende und Entwickler
„Pagemetrics for Matomo“ ist Open-Source-Software. Folgende Menschen haben an diesem Plugin mitgewirkt:
Mitwirkende„Pagemetrics for Matomo“ wurde in 1 Sprache übersetzt. Danke an die Übersetzer für ihre Mitwirkung.
Übersetze „Pagemetrics for Matomo“ in deine Sprache.
Interessiert an der Entwicklung?
Durchstöbere den Code, sieh dir das SVN-Repository an oder abonniere das Entwicklungsprotokoll per RSS.
Änderungsprotokoll
1.1.2
- Tested with WordPress 7.1.
- No functional changes.
1.1.1
- Fixed: the real visitor IP is now forwarded to Matomo as the
cipparameter when an auth token is set, so page views and downloads geolocate the visitor instead of the WordPress server. - New
pm_matomo_tracking_visitor_ipfilter to override the forwarded IP (e.g. from a trusted proxy header) or disable IP forwarding.
1.1.0
- Added AI assistant bot tracking: detects crawls from ChatGPT, Claude, Perplexity and other AI agents and forwards them to Matomo’s AI Assistants report (requires Matomo 5.8.0+).
- New
pm_matomo_tracking_ai_bot_user_agentsfilter to extend the list of detected bot User-Agents.
1.0.0
- Erstveröffentlichung mit serverseitigem Seitenaufruf-Tracking, optionalem Download-Tracking und Multisite-Unterstützung.

