ngx-matomo-client is a robust, actively maintained library providing seamless integration of Matomo (formerly Piwik) analytics into Angular applications. The current stable version is 9.0.1, offering compatibility with Angular 21. The library generally follows Angular's release cadence, providing updates for new major Angular versions, typically within weeks of their release. Key differentiators include its focus on privacy-respecting analytics, explicit support for Angular's module-less applications (since v8.0.0), and the ability to run tracking operations outside Angular's change detection zone for improved performance and stability. This package consolidates functionality previously split across `@ngx-matomo/tracker` and `@ngx-matomo/router` since version 5, simplifying usage and reducing overhead for developers integrating Matomo with Angular's routing.
npm install ngx-matomo-clientVerified import paths — ran on the pinned version, not inferred.
This quickstart sets up Matomo in a standalone Angular application, including router tracking and an example of manually tracking a custom event. Replace `trackerUrl` and `siteId` with your Matomo instance details.
Update all `import` statements to use `ngx-matomo-client`. Refer to the migration guide for specific class and function renames/relocations if upgrading from v4 or older.
Migrate your application's Matomo initialization from `MatomoModule.forRoot()` in `app.module.ts` to `provideMatomo()` in `main.ts` or `app.config.ts`, especially for new standalone components or applications.
Ensure your `ngx-matomo-client` version matches your Angular project's version according to the compatibility table in the package's README. Upgrade both `ngx-matomo-client` and Angular together.
Most applications will benefit from this. If specific scenarios require tracking within the Angular zone, consider wrapping `MatomoService` calls with `ngZone.run()` if absolutely necessary, or ensure your component logic correctly triggers change detection.
Double-check your `trackerUrl` (including `matomo.php` or `piwik.php`) and `siteId` values against your Matomo server configuration. Use your browser's network tab to verify that `matomo.php` requests are being sent correctly.
Ensure `provideMatomo()` is called in your `main.ts` or `app.config.ts` (for standalone applications) or `MatomoModule.forRoot()` (for legacy module-based applications) is imported in your root module.
Check the `ngx-matomo-client` README's compatibility table and align your `ngx-matomo-client` package version with your Angular version. For example, if on Angular 21, use `ngx-matomo-client@9`.
Ensure you are using `ngx-matomo-client` (not legacy `@ngx-matomo/tracker`). Verify your `ngx-matomo-client` version is up-to-date and run `npm install` or `yarn install` to refresh dependencies. Check your `tsconfig.json` for proper type resolution.
Ensure Matomo is initialized before calling tracking methods. For deferred or manual initialization, use `MatomoInitializerService.initialize()` once the necessary configuration (e.g., from an API) is available. For standard setup, ensure `provideMatomo` is correctly configured.