Matomo Statistics Provider

Preconditions

Before you can start using the Matomo Statistics Provider, make sure that the following conditions are met:

Paella Player Configuration

Follow the instructions for the configuration of the Paella Player Matomo user tracking plugin. Make sure that you use the same CustomDimension IDs in the Paella configuration that were assigned to the CustomDimensions in Matomo.

If you are using the Matomo Media Analytics plugin, make sure you configure videoId as the value for the mediaAnalyticsTitle parameter. This will allow the correct statistics to be assigned to the correct event in Opencast.

Access to Matomo

You will need to provide the URL of your Matomo instance and the Matomo auth token in the following config file in order for Opencast to be able to connect to Matomo: etc/org.opencastproject.statistics.provider.matomo.StatisticsProviderMatomoService.cfg

# The URL to use to connect to Matomo
# Default: http://your-matomo-instance.org/
matomo.api.url=https://your-matomo-instance.org/

# The Matomo API token to use to connect to Matomo
matomo.api.token=0123456789abcdef0123456789abcdef

Matomo Statistics Provider Configuration Files

For each Statistic Provider (which corresponds to one graph in the admin UI) you have to create a configuration file in etc/statistics. Configuration files of providers using Matomo have to be named starting with matomo.. All provider configurations have to be in json format. So e.g. matomo.episode.views.sum.json would be a valid name.

For each provider, the following properties have to be configured:

Configuration Example to Access CustomDimension Statistics

The following example generates charts for series with information about the number of visits. The CustomDimension with ID 2 is used to store the series IDs within Matomo.

etc/statistics/matomo.series.views.sum.json

{
    "id": "series.views.sum.matomo",
    "title": "STATISTICS.TITLE.VIEWS_SUM",
    "description": "STATISTICS.DESCRIPTION.VIEWS_SUM",
    "resourceType": "SERIES",
    "sources": [{
      "siteId": "1",
      "dimensionId": "2",
      "method": "CustomDimensions.getCustomDimension",
      "aggregation": "SUM",
      "aggregationVariable": "nb_visits",
      "resolutions": [
        "HOURLY",
        "DAILY",
        "WEEKLY",
        "MONTHLY",
        "YEARLY"
      ]
    }],
    "type": "timeseries"
}

Configuration Example to Access Media Analytics Statistics

The following example generates charts for events with information about the average time the video was watched. This information is only available if the Matomo Media Analytics plugin is in use.

etc/statistics/matomo.episode.time-watched.sum.json

{
    "id": "episode.time-watched.sum.matomo",
    "title": "Time Watched [sec]",
    "description": "Average Time Watched [sec]",
    "resourceType": "EPISODE",
    "sources": [{
      "siteId": "1",
      "method": "MediaAnalytics.getVideoTitles",
      "aggregation": "SUM",
      "aggregationVariable": "avg_time_watched",
      "resolutions": [
        "HOURLY",
        "DAILY",
        "WEEKLY",
        "MONTHLY",
        "YEARLY"
      ]
    }],
    "type": "timeseries"
}

Configuration Example to Access Overall Statistics

The following example generates charts at the organization level with information about the number of visits for all events.

etc/statistics/matomo.organization.visits.sum.json

{
    "id": "organization.plays.sum.matomo",
    "title": "STATISTICS.TITLE.VIEWS_SUM",
    "description": "STATISTICS.DESCRIPTION.VIEWS_SUM",
    "resourceType": "ORGANIZATION",
    "sources": [{
      "siteId": "1",
      "method": "API.get",
      "aggregation": "SUM",
      "aggregationVariable": "nb_visits",
      "resolutions": [
        "HOURLY",
        "DAILY",
        "WEEKLY",
        "MONTHLY",
        "YEARLY"
      ]
    }],
    "type": "timeseries"
}

Limitations