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 FAQ How do I delete rows of a report and specific visits to clean-up some of the reporting data? and in the guide: 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';

Delete actions (pageviews, events…) using a SQL query

Run the following SQL query to delete all actions, in this example all Events, where the “Event action” matches a certain string (in this example my-event-action-to-delete:

    DELETE llva.* 
    FROM matomo_log_link_visit_action llva 
    JOIN matomo_log_action as la  
    WHERE llva.idaction_event_action = la.idaction  
    AND LIKE '%my-event-action-to-delete%';

Or for example, if you tracked in the past some custom events with some bogus data (say an event value that is too large), then you can delete the bogus event actions by running the following SQL queries:

    # First, check the data that will be deleted
    SELECT * FROM matomo_log_link_visit_action WHERE custom_float >= 99999999
    # Then delete the data
    DELETE * FROM matomo_log_link_visit_action WHERE custom_float >= 99999999

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?