Matomo analytics archiving fix

If Matomo-analytics archiving does not work on WordPress site it is most likely caused by plugins inability to read environmental variables which causes following error message:

<h1>Error establishing a database connection</h1> <p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can't contact the database server at <code>$DB_HOST:3306</code>. This could mean your host's database server is down.</p> <ul> <li>Are you sure you have the correct username and password?</li> <li>Are you sure you have typed the correct hostname?</li> <li>Are you sure the database server is running?</li>

Problem can be easily fixed by adding following cron job to crontab:

5 * * * * /usr/local/bin/wp cron event run matomo_scheduled_archive

Cron job can be added to crontab using SSH-connection with command crontab -e

If issue does not get fixed with cron job it is possible that site has active plugins that are not compatible with Matomo-analytics like Wp Rocket and Google Listing and Ads

https://matomo.org/faq/wordpress/which-plugins-is-matomo-for-wordpress-known-to-be-not-compatible-with/

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.