Single visit gets split up into several visits when Matomo server/db is offline


I am trying to cover the situation for when Matomo is not available during a visit to a website.

I host the Matomo web server and the MySQL db with docker containers. If I pause these containers and I visit the website, all events are queued up and eventually fired off when I start the containers again.

However, each event that was fired off during this single visit is seen as its own visit.

All of these visits have the same User ID and the same Visitor ID, even the same timestamp. But they do generate a new Visit ID for each event.

If I pause the containers in the middle of an existing visit, all subsequent events from this visit will get added to the same visit, but in the wrong order once I start the containers again.

My current workaround is to do a custom Ping request to the url of my existing Matomo web server before I start tracking. If no response was given within the timeout, I terminate the tracking completely for this visit. This is not a great solution, because if the Matomo server goes offline in the middle of a visit, things will start to go wrong. I also don’t want to make a ping requests for each event, because waiting for a response from these pings can worsen the user experience. For example, I want to track when a user goes to a different page on the site. If I need to wait for a response from the ping request before tracking this page, then this will cause a delay for the user.

I would like to find a solution where I can continue to track the events (correctly) if Matomo is unavailable.

Does anyone have any suggestions what I can try for this situation? Any help is much appreciated, thank you.