ngx-matomo-client

November 21, 2025 · View on GitHub

← return to documentation

Configuration reference

Below are all configuration properties that you can use when you initialize Matomo (either using provideMatomo(options, ...additionalFeatures) or the classic NgModule):

import {
  provideMatomo,
  withRouter,
  withScriptFactory,
  withRouterInterceptors,
} from 'ngx-matomo-client';

@NgModule({
  providers: [
    provideMatomo(
      // Main options here:
      {
        siteId: 42,
        trackerUrl: 'http://...',
      },

      // Optionally add one or more features:
      withRouter({
        // Router options here
      }),
      withScriptFactory(),
      withRouterInterceptors(),
    ),
  ],
})
export class AppModule {}
See equivalent configuration with @NgModule
import { MatomoModule, MatomoRouterModule, MatomoRouteDataInterceptor } from 'ngx-matomo-client';

@NgModule({
  imports: [
    MatomoModule.forRoot({
      // Main options here
      siteId: 42,
      trackerUrl: 'http://...',
    }),
    MatomoRouterModule.forRoot({
      // Router options here
    }),
  ],
})
export class AppModule {}

Options

Main configuration options (for provideMatomo() or MatomoModule.forRoot()) are:

OptionTypeDefault valueDescriptionAvailable in 'manual' mode
modeMatomoInitializationBehavior'auto'Set whether tracking code should be automatically embedded or not.
If set to 'manual', some other option cannot be used.
-
siteIdnumber or stringrequired, unless trackers is setYour Matomo site id (may be found in your Matomo server's settings).no
trackerUrlstringrequired, unless trackers is setYour Matomo server url.no
trackerUrlSuffixstringmatomo.phpSuffix to append to trackerUrl.no
trackersarray of {siteId: string, trackerUrl: string, trackerUrlSuffix?: string}none, required unless siteId and trackerUrl are setA list of multiple Matomo servers. Note that tracking code will be downloaded from the FIRST tracker in the list (unless scriptUrl option is set). Mutually exclusive with the three previous options.no
scriptUrlstringtracker url suffixed with matomo.jsUrl of Matomo tracker's script.no
disabledbooleanfalseIf set to true then all tracking operations become no-op. Note that in this case, all getter methods will return rejected Promises.yes
trackAppInitialLoadbooleanfalse if router is enabled, true otherwiseIf set to true, will call trackPageView on application init. This should probably never be used on a routed single-page application.yes
enableLinkTrackingboolean or 'enable-pseudo'trueIf set to true (the default), enable link tracking, excluding middle-clicks and contextmenu events.
If set to enable-pseudo, enable link tracking, including middle-clicks and contextmenu events.
If set to false, disable link tracking.
yes
enableJSErrorTrackingbooleanfalseIf set to true, enable JS errors tracking.yes
acceptDoNotTrackbooleanfalseSet whether to not track users who opt out of tracking using Do Not Track settingyes
requireConsentMatomoConsentRequirement'none'Configure user consent requirement.yes
runOutsideAngularZonebooleantrueIf set to true, will run matomo calls outside of angular's NgZone. This may help if the call causes the app to freeze. This has no effect in zoneless applications.yes

Router configuration options (for withRouter() or MatomoRouterModule.forRoot()) are:

OptionTypeDefault valueDescription
prependBaseHrefbooleantrueSet whether the application's base href should be prepended to current url when tracking page views. Set it to false to disable this behavior.
trackPageTitlebooleantrueSet whether to detect page title when tracking views.
By default, page title is automatically detected from DOM document title.
Note that if set to false, Matomo is likely to still use the initial document title for all tracked page views.
delaynumber
Set to -1 to run synchronously
0 (no delay but still asynchronous)Set a delay after navigation event before page view is tracked.
If your document title is updated asynchronously after Router events, you may have to set a delay to correctly detect document title.
If set to 0, tacking is still asynchronous. Set it to -1 to execute tracking synchronously.
See also previous sections for more advanced page title customization.
excludestring, RegExp, string[] or RegExp[][]Set some url patterns to exclude from page views tracking.

Additional features

Available features for provideMatomo() are:

withRouter

Enable automatic page view tracking. This requires @angular/router.

See options for router configuration above.

withRouteData

Add automatic Matomo data retrieval from Angular routes configuration. This requires withRouter() feature. See Using route data in README for details.

withRouterInterceptors

Add interceptors to hook into the automatic page view tracking. This requires withRouter() feature. See Using custom interceptor in README for details.

withScriptFactory

Allow to customize Matomo's script element creation. See How can I customize the inserted script tag? in FAQ.

withFormAnalytics

Allow to use the Form Analytics plugin of Matomo. See Plugins > Form Analytics in FAQ.