An addon that provides a metrics-adapter for Matomo for ember-metrics.
- Lazy initialization
- Fastboot aware
- Ember.js v3.16 or above
- Ember CLI v2.13 or above
- Node.js v10 or above
ember install ember-metrics-matomo-adapter
Configure the adapter in config/environment.js
as any other adapter for
ember-metrics:
metricsAdapters: [
{
name: 'Matomo',
environments: ['development', 'production'], // see ember-metrics docs
config: {
scriptUrl: '//cdn.matomo.cloud/<your-domain>.matomo.cloud',
trackerUrl: 'https://<your-domain>.matomo.cloud',
siteId: '<your-site-id>',
disableCookies: true // <- for GDPR
}
}
]
You can use the adapter as you would any other ember-metrics
-metrics-adapter:
// app/routes/application.ts
import Route from '@ember/routing/route';
import RouterService from '@ember/routing/router-service';
import { inject as service } from '@ember/service';
import MetricsService from 'ember-metrics/services/metrics';
export default class ApplicationRoute extends Route {
@service declare readonly metrics: MetricsService;
@service declare readonly router: RouterService;
constructor() {
super(...arguments);
this.setupTracking();
}
private setupTracking() {
this.router.on('routeDidChange', () => {
const { currentURL, currentRouteName } = this.router;
this.metrics.trackPage({
page: currentURL,
title: currentRouteName,
});
});
}
}
Matomo implements some methods that aren't part of ember-metrics
main api. These methods can be called through ember-metrics
invoke
.
Below is a list of Matomo-specific methods that are implemented by ember-metrics-matomo-adapter
.
-
trackSiteSearch
this.metrics.invoke('trackSiteSearch', { keyword: 'myKeyWord', category: 'myCategory', searchCount: 2, });
See the Contributing guide for details.
This project is licensed under the MIT License.