Reports only show if user is authenticated to Matomo

Created on 17 May 2025, 3 months ago

Problem/Motivation

Hi,

We're using this module on a site to pull Matomo reports into the Drupal report section. Two users do have their own logins to Matomo, but most other admins do not -- so we set up a dedicated Matomo user with an access token and put it in the settings. However, now normal Drupal users get an error in each iframe saying they must log in to proceed.

Steps to reproduce

1. Create a limited Matomo user with view access to the data.
2. Create an access token in Matomo.
3. Add the token to the global config for this module.
4. Log out of Matomo.
5. Visit the reports in Reports -> Matomo reports.

You don't get any reports loading -- just login errors/boxes.

Proposed resolution

Testing the iframe URLs, I see the same login error when accessing the URL directly. Comparing the generated URL with widget code taken from the Matomo admin area, I see one GET parameter difference -- the Drupal site is adding force_api_session=1 . With this GET parameter, I cannot load the widget unless I am authenticated with Matomo. Omitting that parameter allows the widget to load.

Remaining tasks

I'm not sure whether this parameter is needed at all -- is it necessary to support user-specific tokens? If not, can we simply remove this parameter entirely?

I found that if I comment out the 3 places this token appears in the module, reports now load for everyone.

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States freelock Seattle

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024