Mautic Know-How
Mautic Know-How
Mautic Tutorials for Beginners & Tips for Specialists

Housekeeping: Help the Mautic Datenbank Stay Lean

The Mautic database tends to grow huge very quickly, especially when integrated on higher-traffic web sites. A large percentage is basically junk, though. Here are some simple tricks to reduce that drastically.

Note that at the same time this addresses GDPR requirements for deleting old data.


Cron Jobs for Cleanup

Mautic comes with simple console command for clean-up pruposes, see for details.

a) Cleanup data

For audit log entries, anonymous contacts, and visitor page hits) older than a certain age: 

php /path/to/mautic/app/console mautic:maintenance:cleanup --days-old=365 --dry-run

You can also add the ‘--gdpr’ flag to delete known leads that have been inactive for 3 years.

b) Clean up unused IPs

Deletes IP addresses that are not used in any other database table:

php /path/to/mautic/app/console mautic:unusedip:delete


Clean up via Housekeeping Plugin by Leuchtfeuer

Some of the constantly growing database tables are not yet covered by an in-house cleanup-command and thus might reach exorbitant dimensions.

To keep that database growth under control we developed the Housekeeping Plugin. It covers the deletion of data from the following tables, which are normally deemed to rack up a lot of data over time:

  • lead_event_log
  • campaign_lead_event_log
  • email_stats
  • email_stats_devices

Need a tutorial on how this plugin works exactly and the possibilities of configuration? Then take a look at his knowledgebase article right here:
Tutorial - Housekeeping Plugin

You can download the plugin here:

Attention!: Potential user data is cleaned here! Campaign and segment memberships will of course remain, but the contact history will be cleared of when and why the contacts entered the segment or campaign. 


Campaigns for contact cleanup

Now here comes the charming part: Why not use Mautic to clean up Mautic?

The basic idea is:

  • Define criteria for what you want to get rid of
  • Create segment(s) with filters to reflect those criteria
  • Create campaign to delete contacts in those segments

Example 1: "Single-Click Users (before yesterday)"

Anononymous users with just a single click can occur for various reason (bots, non-cookie visitors, ...) - in most cases they are considered junk. So why not get rid of them?

Segment filters:
"Visited URL Count equals 1"
"Visited URL Date less than -2 days"

Example 2: "Delete certain contacts that have been inactive for more than 60 days"

If you want to be more granular than "mautic:maintenance:cleanup" (and especially than the --gdpr flag), you can use the same trick as before, e.g. 

Segment filters:
"Visited URL Date less than -60 days"

and combine this with other criteria of your choice (e.g. score).

Your browser is outdated!

Please update your browser to see this website correct. Update your browser now