MATOMO ON-PREMISE ONLY

There are a few cases where you need to re-process some historical data directly from the raw logs.

For example a common use case is when you use the HTTP Tracking API to manually insert visits and actions in Matomo (Piwik) in the past (via the Tracking API parameter cdt which lets you define the date and time of the page view). If you set this date to a date in the past (for example, 3 days ago) and that Matomo has already processed the statistics reports for this date, you will not see the newly added data in Matomo.

Another example is when you create Custom Reports, or Funnels, and want to see the Custom report data and Funnel data for past dates as well. It is also useful when changing settings in the config file such as reporting more than the default 500 rows.

To tell Matomo to invalidate historical aggregated data for a website (or several), a date range (or for all past data), a segment (or for all segments), there are 3 similar techniques you can use.

1) Use the InvalidateReports plugin

You can use this free plugin by InnoCraft to invalidate your historical data directly within the user interface in just one click: get the InvalidateReports plugin. If you need to often invalidate historical data, this may be the easiest solution.

After the Invalidate Reports plugin finishes installing, you can see it here:
Matomo >> ⚙️ >> System >> Invalidate Reports.

2) Use a console command

Alternatively you may use the core:invalidate-report-data console commmand:

./console core:invalidate-report-data --dates=2011-10-15,2012-01-01 --sites=1,3,5

3) Use the HTTP API

You can use the API function: CoreAdminHome.invalidateArchivedReports. For example if you imported data in the past for a few specific websites on a couple different dates you could write:

?module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=1,3,5&dates=2011-10-15,2012-01-01&token_auth=xyz

It is possible to invalidate and re-process a segmented report only, simply add to the URL query the segment parameter: &segment=pageUrl=@example.org/contact.

In rare cases you may want to delete reports for a particular period (one of: day, week, month, year, range): setting the &period= parameter to the API call will force Matomo to only invalidate reports of the specified period.

Notes

  • Your historical data will be actually re-processed the next time auto archiving will run. The archiving will re-process the reports data for these particular dates and websites.
    You can also manually run the archive command with:
./console core:archive --force-all-websites --url=YOUR_MATOMO_URL_HERE

.
You can also specify a specific date range to archive after invalidating reports:

./console core:archive --force-all-websites --force-date-range=2011-10-15,2012-01 --url=YOUR_MATOMO_URL_HERE

(or if you are using Matomo 3.x, run the following command: ./console core:archive --force-all-websites --force-all-periods=315576000 --force-date-last-n=1000 --url=YOUR_MATOMO_URL_HERE)

  • when invalidating report for a period eg. week it automatically invalidates all periods that include this one, eg. the enclosing month and year. We say the invalidation cascades up. By default, periods that are included are not invalidated (invalidating month will not re-process the days and weeks within the month). You may also force Matomo to invalidate inner periods by setting the parameter &cascadeDown=1 (in the CoreAdminHome.invalidateArchivedReports API) or --cascade (in the core:invalidate-report-data command).
Previous FAQ: How do I track and measure how my Matomo service is being used?