Skip to main content

Session Computation Command

The mautic:analytics:rebuild command processes page hits from Mautic’s tracking and computes visitor sessions.
php bin/console mautic:analytics:rebuild [options]

Options

OptionDescription
(none)Incremental update - processes only new hits since last run
--rebuildFull rebuild - truncates tables and reprocesses all data
--days=NLimit rebuild to last N days (use with --rebuild)

Usage Examples

Incremental Update (Default)

php bin/console mautic:analytics:rebuild
This is the fastest option. It only processes new page hits since the last run. Use this for your regular cron job.

Full Rebuild

php bin/console mautic:analytics:rebuild --rebuild
Truncates all session data and reprocesses everything from scratch. Use this if you need to regenerate all session data.

Rebuild Last 90 Days

php bin/console mautic:analytics:rebuild --rebuild --days=90
Rebuilds session data but only for the last 90 days. Good for initial setup or when you want to limit processing time.

Rebuild Last 7 Days

php bin/console mautic:analytics:rebuild --rebuild --days=7
Quick rebuild for testing or when you only need recent data.

Cron Setup

For real-time analytics, run the command regularly via cron:
# Every 5 minutes (recommended for active sites)
*/5 * * * * php /path/to/mautic/bin/console mautic:analytics:rebuild

# Every 15 minutes (for less active sites)
*/15 * * * * php /path/to/mautic/bin/console mautic:analytics:rebuild

# Every hour (minimum recommended frequency)
0 * * * * php /path/to/mautic/bin/console mautic:analytics:rebuild

Output

The command outputs statistics about its run:
Processing 1,234 page hits
Completed: 456 sessions from 1,234 hits in 0.52s
This shows:
  • How many page hits were processed
  • How many sessions were created
  • How long the processing took