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

Tutorial - Housekeeping Plugin for Mautic

With our housekeeping plugin for Mautic, you can easily keep your database lean. Which functions the plugin offers and how to use it sensibly is explained in this tutorial!

Installing the plugin

The plugin is freely available for download on GitHub: 
https://github.com/Leuchtfeuer/mautic-housekeeping-bundle

The following steps are necessary for the installation: 

  1. Download the .zip file
  2. Transfer the .zip file to ../htdocs/plugins
  3. Unpack 
  4. Rename the unzipped folder to "MauticHousekeepingBundleā€¯
  5. Cache clear
  6. Reload plugins
     

Console command

After the successful installation of the plugin, the following new Mautic command is now available: bin/console leuchtfeuer:housekeeping

If this command is executed without further parameters, all lead_event_log campaign_lead_event_log, email_stats & email_stats_devices entries older than 365 days are deleted

Find out how a more granular deletion of data works thanks to different parameters.
 

Parameter

The trial run | --dry-run

If you first want to familiarise yourself with the amount of data that would be deleted, you can provide your delete command with "--dry-run" or also "-r". Thanks to this parameter, the data is only being counted and not yet deleted. 

Deletion period | --days-old

The parameter "--days-old" or in short "-d" enables the definition of a time period for the deletion of the data. The time span is specified in days and interpreted as "older than X days". 

Example:
leuchtfeuer:housekeeping --days-old 100

Here, all data from the tables listed above that are older than 100 days are deleted.
 

Campaign activity of leads | --campaign-lead

The table "campaign_lead_event_log" saves the campaign activities of contacts. In the history of a contact, these activities are represented by the individual steps:

If there are many contacts and campaigns with several steps, this table can grow quickly. Therefore, this table should also be cleaned up. 

It should be noted that the last step of a campaign that has already been run always remains in place to prevent contacts from unintentionally running through campaigns again. 

Deletion is done with the parameter "--campaign-lead" or "-c". Furthermore, there is an additional parameter "--cmp-id" or "-i". This enables the deletion of data from a single selected campaign.

Example:
leuchtfeuer:housekeeping --campaign-lead -i 58

This deletes all entries in the campaign_lead_event_log table that are produced by the campaign with ID 58 and are older than 365 days. 

Such a campaign-specific deletion makes sense if this campaign generates a large data load. Campaigns that have either many steps or campaigns that are basically run through by all contacts once or several times are susceptible to this.


Activity of leads | --lead

The lead_event_log table stores entries such as joining/leaving segments as well as campaigns, but also changes to contact information, such as through a CSV import etc. So a whole range of different information - this table can therefore also grow exponentially. 

Deletion is done with the parameter "--lead" or "-l", there are no other parameters for this command.

Example:
leuchtfeuer:housekeeping --lead --days-old 100

All entries of the Lead_event_log that are older than 100 days are deleted.


Email statistics | --email-stats

It is not unusual that a large number of emails is being sent from Mautic. For each email sent, an entry is created in the email_stats table - which is quite a flood of data in terms of duration and quantity sent.

First of all, it must be said - just because an entry is deleted from the email_stats table, it does not mean that the email will be sent again! 

Only the entry is removed from the contact history. In addition, the bars "Emails sent" & "Email read" in the are no longer displayed in the detailed view of an email; the absolute numbers do not change as a result. 

Furthermore, after deleting the email_stats for an email, no more link clicks are counted, even if the email should be opened again by the lead and links should be clicked.

Deletion is done with the parameter "--email-stats" or "-m".

Example:
leuchtfeuer:housekeeping --email-stats --days-old 100

Here, all email_stats entries older than 100 days are deleted. Complementary to this, the linked entries are also deleted from the email_stats_devices table. This table stores the information with which device an email was opened. Since this information is practically worthless without an associated email_stats entry, the entries are also deleted.


Email Tokens | --email-stats-tokens

If deleting whole email_stats entries seems too heavy, it is possible to delete only the content of the tokens column instead of a whole email_stats entry. 

The column tokens contains information that is relevant for the browser view of an email - more precisely, the links for the browser view. If the tokens for an email are deleted and the email is subsequently opened again in the browser view, the links are no longer functional and lead to a 404 error - in the email client, however, they work without any problems.

As the tokens are the largest amount of data of an email_stats entry, it is worthwhile to delete old tokens, as they consume a lot of memory for only one niche use. 

Deletion is done with the parameter "--email-stats-tokens" or "-t".

Example:
leuchtfeuer:housekeeping --email-stats-tokens --days-old 14

All email_stats_tokens entries older than 14 days are deleted here.

Your browser is outdated!

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