# Class MatomoAnalyticsProvider

java.lang.Object
com.codename1.analytics.AbstractAnalyticsProvider
com.codename1.analytics.MatomoAnalyticsProvider

All Implemented Interfaces:
  `AnalyticsProvider`

public class MatomoAnalyticsProvider extends AbstractAnalyticsProvider

A privacy-first 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

  Constructors
  Constructor
  Description
  `MatomoAnalyticsProvider(String matomoBaseUrl, int idSite)`
  Creates a Matomo provider.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getName()`
  A short, stable, human readable name for this provider (used in logs and diagnostics).
  `void`
  `reportCrash(AnalyticsCrashReport report)`
  Reports a crash or handled exception.
  `void`
  `setUserId(String id)`
  Associates subsequent activity with a user identifier.
  `boolean`
  `supports(AnalyticsCapability capability)`
  Indicates whether the provider supports a given capability.
  `void`
  `trackEvent(AnalyticsEvent event)`
  Records a named event.
  `void`
  `trackScreen(String name, String referrer)`
  Records a screen / page view.

  ### Methods inherited from class AbstractAnalyticsProvider

  `flush, getContext, init, onConsentChanged, setUserProperty`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### MatomoAnalyticsProvider

    public MatomoAnalyticsProvider(String matomoBaseUrl, int idSite)

    Creates a Matomo provider.

    ###### Parameters

    - `matomoBaseUrl`: the Matomo base URL or full `matomo.php` tracker URL

    - `idSite`: the Matomo site id

- ## Method Details

  - ### getName

    public String getName()
    Description copied from interface: `AnalyticsProvider`

    A short, stable, human readable name for this provider (used in logs and diagnostics).

    ###### Returns

    the provider name

    Specified by:
      `getName` in interface `AnalyticsProvider`
    Specified by:
      `getName` in class `AbstractAnalyticsProvider`

  - ### setUserId

    public void setUserId(String id)
    Description copied from interface: `AnalyticsProvider`

    Associates subsequent activity with a user identifier.

    ###### Parameters

    - `id`: the user id, or null to clear
    Specified by:
      `setUserId` in interface `AnalyticsProvider`
    Overrides:
      `setUserId` in class `AbstractAnalyticsProvider`

  - ### trackScreen

    public void trackScreen(String name, String referrer)
    Description copied from interface: `AnalyticsProvider`

    Records a screen / page view.

    ###### Parameters

    - `name`: the screen name

    - `referrer`: the previous screen name, may be null

    Specified by:
      `trackScreen` in interface `AnalyticsProvider`
    Overrides:
      `trackScreen` in class `AbstractAnalyticsProvider`

  - ### trackEvent

    public void trackEvent(AnalyticsEvent event)
    Description copied from interface: `AnalyticsProvider`

    Records a named event.

    ###### Parameters

    - `event`: the event
    Specified by:
      `trackEvent` in interface `AnalyticsProvider`
    Overrides:
      `trackEvent` in class `AbstractAnalyticsProvider`

  - ### reportCrash

    public void reportCrash(AnalyticsCrashReport report)
    Description copied from interface: `AnalyticsProvider`

    Reports a crash or handled exception.

    ###### Parameters

    - `report`: the crash report
    Specified by:
      `reportCrash` in interface `AnalyticsProvider`
    Overrides:
      `reportCrash` in class `AbstractAnalyticsProvider`

  - ### supports

    public boolean supports(AnalyticsCapability capability)
    Description copied from interface: `AnalyticsProvider`

    Indicates whether the provider supports a given capability.

    ###### Parameters

    - `capability`: the capability to query

    ###### Returns

    true if supported

    Specified by:
      `supports` in interface `AnalyticsProvider`
    Overrides:
      `supports` in class `AbstractAnalyticsProvider`