Sometimes, you may need to delete some or all Visits log data for a given date, and/or a given website. For example if you have imported log files incorrectly in Matomo (Piwik) you may want to delete the invalid data that was imported.

Delete visits using the UI

As part of the GDPR Privacy features in Matomo, you can easily delete visits. Learn more in the GDPR Guide “Right to erasure”.

Delete visits using a console command

A console command lets you delete all visits log data (including Visits, Actions, Goal conversions, Ecommerce activity).

To use this console command, login to your server (using SSH) and go in the Matomo directory. Execute the following command to display the help:

./console help core:delete-logs-data

The following options are available:

  • --dates lets you delete log data with a date within this date range. Eg, 2012-01-01,2013-01-01
  • --idsite lets you delete log data belonging to the site with this ID. Comma separated list of website id. Eg, 1, 2, 3, etc. By default log data from all sites is purged.
  • --limit lets you pick the number of rows to delete at a time. The larger the number, the more time is spent deleting logs, and the less progress will be printed to the screen. (default: 1000)

For example to delete all log data for month of January 2015 on website ID 42, execute:

./console core:delete-logs-data --dates=2015-01-01,2015-01-31 --idsite=42


  • all the visits log data for the given date range and website ID will be permanently deleted.
  • this console command does not delete your archived report data but only delete the raw visits log data.

Delete visits using SQL query

Run the following SQL query to delete visits matching a certain criteria, for example here we delete all visits where the screen resolution wasn’t tracked properly in the date range 2019 May 1st-May 16th:

DELETE log_visit, log_link_visit_action, log_conversion 
FROM log_visit 
LEFT JOIN log_link_visit_action ON log_visit.idvisit = log_link_visit_action.idvisit 
LEFT JOIN log_action ON log_action.idaction = log_link_visit_action.idaction_url 
LEFT JOIN log_conversion ON log_visit.idvisit = log_conversion.idvisit 
WHERE config_resolution = 'unknown' 
AND visit_last_action_time >= '2019-05-01' 
AND visit_last_action_time <= '2019-05-16';

Related FAQs

If you want to configure Matomo to automatically purge your old data (whether visits log data, or statistics reports data), see this FAQ How do I delete historical Matomo data? (purge old logs and/or old processed reports)

If you want to delete old reports, read this FAQ: How do I delete all statistics for a given website, or for all websites?