LW IT Solutions logo LW IT Solutions logo LW IT Solutions
« Blog Overview /Digital Analytics / Preparing Matomo Reports: Cron, Waiting Time and...
Read this article in other languages:

Preparing Matomo Reports: Cron, Waiting Time and Freshness

Preparing Matomo Reports: Cron, Waiting Time and Freshness

Summary

Matomo turns recorded website visits into reports about traffic and behaviour. If those reports are calculated only when opened, the wait can be long. Scheduled background processing prepares frequently needed results in advance, making reports available sooner. This is especially useful for a self-hosted Matomo installation with regular reporting needs. The schedule must cover the required filters and periods, while successful completion determines how current the results are.

Contents
  1. Summary
  2. 1. Reports prepared in advance
  3. 2. A working schedule first
  4. 3. Browser triggering and report freshness
  5. 4. Segments and custom periods
  6. 5. Successful runs and storage
  7. Questions and answers
  8. Sources

Matomo first stores individual visits and actions. Reports require the server to turn those records into totals and tables. Matomo calls this archiving. If the required prepared report is missing, opening a dashboard can start the calculation. The browser then waits for the server.

A cron job starts this work on a schedule, for example once an hour. Frequently needed reports can then be ready before the dashboard opens. The calculation still needs processing capacity; its timing changes. This does not guarantee a fixed loading time or failure-free operation.

The following steps apply to a standalone Matomo On-Premise installation. Matomo Cloud manages scheduling itself; Matomo for WordPress uses WP-Cron. The technical rules were checked against Matomo 5.14.2.

1. Reports prepared in advance

Matomo stores raw records in tables such as matomo_log_* and calculated report data in matomo_archive_*; the shared matomo_ name prefix can differ. Daily reports use raw records. Weekly and monthly reports can build on daily archives. Opening a monthly report therefore does not necessarily reread every raw record.

core:archive checks which reports need recalculation after new data or changes. It also processes saved segments marked for preparation in advance. A segment is a filter, such as “visits from Germany on a mobile device”.

The browser can trigger calculation; the server performs it. A schedule prepares required reports when runs complete successfully.
The browser can trigger calculation; the server performs it. A schedule prepares required reports when runs complete successfully. # · WebP

2. A working schedule first

The following is an example for a system crontab under /etc/cron.d/. Paths and account must match the installation. The log directory must already exist and be writable by www-data.

5 * * * * www-data /usr/bin/php /var/www/matomo/console core:archive >> /var/log/matomo/archive.log 2>&1

The job starts five minutes past each hour. www-data is the execution account; a personal crontab omits this extra field. >> appends output, while 2>&1 sends error output to the same file. Regularly starting a new log file and removing older files after a set period prevents unlimited growth. Since both output streams go to the file, this line does not provide an error notification.

A successful test run under the intended account and PHP version is needed before disabling browser triggering. Missing permission to write the log can prevent the command from starting. A run may also take longer than an hour. Its interval, scope or deliberately configured parallel processing must then be adjusted.

The checked Matomo 5.14.2 command includes --url without marking it deprecated. The Matomo address can be needed especially when archiving falls back to HTTP requests. This simple example omits the option, as the command help recommends.

3. Browser triggering and report freshness

Administration → System → General Settings provides the switch for archiving when reports are viewed. The same area controls the interval before current reports can be calculated again. An hourly job and 3,600 seconds are a common starting point.

The schedule and archive lifetime do different jobs: cron starts the check; the lifetime determines whether an existing archive is ready for recalculation. A 09:05 run therefore does not guarantee a report complete exactly through 09:00. Runtime, backlog and actual successful completion determine freshness.

Values saved in the interface override the corresponding defaults in config/config.ini.php while the administration page is enabled. Weeks, months, years and custom date ranges can also have separate lifetimes. The value 3,600 therefore need not control every report.

Two exceptions remain after disabling the general browser trigger. Real-time segments can still start calculations, and custom date ranges can do so too. The following addition to the existing [General] section closes both paths, provided the general browser trigger is actually off:

[General]
browser_archiving_disabled_enforce = 1
archiving_range_force_on_browser_request = 0

This stricter setting makes sense only after the required segments and periods have been included in background processing. Otherwise a report may be unavailable instead of slow. global.ini.php contains defaults and is not the file for local changes.

4. Segments and custom periods

A segment saved for preprocessing is calculated by the background run. Its first run can take a long time. process_new_segments_from limits how far back the calculation goes; the default includes available history. Raw records already deleted are unavailable for new historical analyses.

With browser triggering off, a real-time segment can still be calculated on request only if the additional restriction permits it. browser_archiving_disabled_enforce = 1 closes that exception for ordinary periods. The two settings therefore need to be considered together.

Matomo 5.14.2 includes selected ranges from account preferences and entries under archiving_custom_ranges[]. A regularly needed custom period must be included accordingly. An arbitrary newly selected range is not automatically ready when the dashboard opens.

5. Successful runs and storage

Useful checks include the last successful run, runtime, error messages and the age of important reports. A cron entry alone does not prove that processing works. Matomo summarises detected archiving errors; additional files or emails depend on logging settings, output redirection and configured mail delivery.

Preparing more segments and periods can use more storage. Cron does not inevitably enlarge the database: browser-triggered calculations store archives too. Scope, repeated processing and retention matter. Optimising every table after each run is not a necessary part of this change.

Questions and answers

Does the dashboard become fast immediately?

Existing archives avoid waiting for their calculation. Database access, networks, plugins and the browser still take time. A before-and-after measurement establishes the actual improvement.

Does a 15-minute interval mean four times the work?

It provides four times as many opportunities to start. Actual recalculation also depends on new data, archive lifetime and runtime.

Must the account match the web server?

This is often the simplest way to keep file permissions compatible. Another account is possible if shared cache and working files remain accessible to both processes. A root run can otherwise leave files that the web server cannot later modify.

Are email reports then guaranteed?

The archiver can also run scheduled tasks. Delivery schedules, permissions and mail transport still need to work; cron alone does not confirm successful delivery.

Lukas Wojcik

Lukas Wojcik

Systems architect and technology enthusiast specializing in scalable tracking solutions, GMP Stack (GA4 & GTM), and robust backend architectures. Advocate for clean code and privacy-first design.

Get in touch

A question or an idea for a web project? Tell me a little about it. This form uses reCAPTCHA and formconfirmed to protect against spam.

Write a comment

Differing figures from other accounts and questions about the setup are welcome here.

The email address is not published. Required fields are marked with an asterisk.

LUKASWOJCIK.COM · NEWSLETTER

Fresh ideas in your inbox

New articles, practical tools and updates from the projects.

Choose topics (optional)
No selection: all topics.

Subscription starts after confirmation by email. · Privacy

Privacy · Newsletter

Email address, language, selected topics and subscription/confirmation dates are stored to deliver the newsletter. Double opt-in is required. Every issue includes an immediate unsubscribe link. Formconfirmed checks the signup for spam. No email open or click tracking.

Read the full privacy policy ↗