How do I delete all statistics for a given website, or for all websites?
The easiest way to delete all data for a website is to delete the Website in Matomo directly. This will delete all data.
But sometimes you want to keep your Website in Matomo to keep the same Website ID (and tracking code). So you can also follow the steps to delete all the data for a website, without deleting the website itself.
Advanced instructions
It is possible to keep all the websites information (names, defined goals, etc.) and only delete the stored analytics data. There is not currently a tool available to delete all data automatically, but you can manually delete all data for a specific website directly within the database server.
Connect to your Mysql database storing your Matomo (Piwik) data with your favorite database client (for example phpMyadmin) and do the following:
-
To delete statistics data for all websites, run the following query for each matomo_archive_* table:
DROP TABLE matomo_archive_numeric_Y, matomo_archive_blob_Y;
-
To delete statistics data for a given website, run the following query for each matomo_archive_* table:
DELETE FROM matomo_archive_numeric_Y, matomo_archive_blob_Y WHERE idsite = X;
The archive tables will automatically be re-created from the Visitor logs when Matomo processes your reports (assuming you do not purge your old visitor log data).
-
To delete log data for a given website, execute the following query:
DELETE FROM matomo_log_visit WHERE idsite = X; DELETE FROM matomo_log_link_visit_action WHERE idsite = X; DELETE FROM matomo_log_conversion WHERE idsite = X; DELETE FROM matomo_log_conversion_item WHERE idsite = X;
with X replaced by the website ID you wish to reset.
The alternative solution is to use the Delete old reports and Delete old tracking data features, click to see the FAQ.
If you want to delete Visitor log data (and not Report data) then read this FAQ: How do I delete old visitors statistics for a given website and/or date?