Class MatomoAnalyticsProvider
- All Implemented Interfaces:
AnalyticsProvider
A privacy-first, non-Google provider targeting Matomo (formerly Piwik) through its HTTP Tracking API. Matomo can be self-hosted and offers IP anonymisation and consent-aware tracking, which makes it a natural fit for GDPR-sensitive deployments. The same SPI shape applies to comparable privacy-focused backends (PostHog, Plausible), so swapping is trivial.
Analytics.addProvider(new MatomoAnalyticsProvider("https://matomo.example.com", 1));
Screen views map to Matomo actions; events use Matomo's e_c/e_a/e_n
event parameters; crashes are reported as an event in the crash category.
The pseudonymous client id is truncated to Matomo's 16-character visitor id.
-
Constructor Summary
ConstructorsConstructorDescriptionMatomoAnalyticsProvider(String matomoBaseUrl, int idSite) Creates a Matomo provider. -
Method Summary
Modifier and TypeMethodDescriptiongetName()A short, stable, human readable name for this provider (used in logs and diagnostics).voidreportCrash(AnalyticsCrashReport report) Reports a crash or handled exception.voidAssociates subsequent activity with a user identifier.booleansupports(AnalyticsCapability capability) Indicates whether the provider supports a given capability.voidtrackEvent(AnalyticsEvent event) Records a named event.voidtrackScreen(String name, String referrer) Records a screen / page view.Methods inherited from class AbstractAnalyticsProvider
flush, getContext, init, onConsentChanged, setUserProperty
-
Constructor Details
-
MatomoAnalyticsProvider
Creates a Matomo provider.
Parameters
-
matomoBaseUrl: the Matomo base URL or fullmatomo.phptracker URL -
idSite: the Matomo site id
-
-
-
Method Details
-
getName
Description copied from interface:AnalyticsProviderA short, stable, human readable name for this provider (used in logs and diagnostics).
Returns
the provider name
- Specified by:
getNamein interfaceAnalyticsProvider- Specified by:
getNamein classAbstractAnalyticsProvider
-
setUserId
Description copied from interface:AnalyticsProviderAssociates subsequent activity with a user identifier.
Parameters
id: the user id, or null to clear
- Specified by:
setUserIdin interfaceAnalyticsProvider- Overrides:
setUserIdin classAbstractAnalyticsProvider
-
trackScreen
Description copied from interface:AnalyticsProviderRecords a screen / page view.
Parameters
-
name: the screen name -
referrer: the previous screen name, may be null
- Specified by:
trackScreenin interfaceAnalyticsProvider- Overrides:
trackScreenin classAbstractAnalyticsProvider
-
-
trackEvent
Description copied from interface:AnalyticsProviderRecords a named event.
Parameters
event: the event
- Specified by:
trackEventin interfaceAnalyticsProvider- Overrides:
trackEventin classAbstractAnalyticsProvider
-
reportCrash
Description copied from interface:AnalyticsProviderReports a crash or handled exception.
Parameters
report: the crash report
- Specified by:
reportCrashin interfaceAnalyticsProvider- Overrides:
reportCrashin classAbstractAnalyticsProvider
-
supports
Description copied from interface:AnalyticsProviderIndicates whether the provider supports a given capability.
Parameters
capability: the capability to query
Returns
true if supported
- Specified by:
supportsin interfaceAnalyticsProvider- Overrides:
supportsin classAbstractAnalyticsProvider
-