How to Set Different Data Retention Periods for Individual Websites?

Hi everyone,

I’m using Matomo to analyze user behavior across multiple websites. I want to automatically delete raw data for each website after different retention periods. For example, I’d like to delete data for Website A after 2 years, and for Website B after 5 years.

However, I noticed that the data retention settings in Matomo apply globally to all websites. Is there any way to configure individual data retention periods per website?

Any suggestions or workarounds would be greatly appreciated!

Thanks!

1 Like

Hi there,

Not in the UI, You could potentially create a cron job to run this for example for 60 days retention.

:fire: All code supplied untested, use at your own risk,

#!/bin/bash

# Calculate the date 60 days ago
end_date=$(date -d "60 days ago" +"%Y-%m-%d")

# Run the Matomo delete logs command to delete data older than 60 days
/path/to/your/matomo/console core:delete-logs-data --dates=1970-01-01,${end_date} --idsite=42

How do I delete old visitors statistics for a given website and/or date? FAQ - How to - Matomo Analytics Platform