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 REST 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 (Piwik) 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.
2) Use a console command
Alternatively you may use the
core:invalidate-report-data console commmand:
./console core:invalidate-report-data --dates=2012-01-01,2011-10-15 --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:
It is possible to invalidate and re-process a segmented report only, simply add to the URL query the segment parameter:
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 (Piwik) to only invalidate reports of the specified period.
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.
when invalidating report for a period eg.
weekit automatically invalidates all periods that include this one, eg. the enclosing
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 (Piwik) to invalidate inner periods by setting the parameter