Matomo previously known as Piwik is an analytic tool which can be installed on-premise. It is a Google Analytics alternative with data in your control. If you want to install and setup an analytic tool on your server for different reasons, Matomo is the one you should be looking to install.
Plausible is an alternative to Google Analytics and Matomo. It is a web based analytics software which you can self-host too on your own server. They also provide cloud accounts to host your data on their servers like Google Analytics. Here I will guide you how to setup Plausible on Ubuntu 22.04 with Apache as proxy and SSL certificate from Let's encrypt on your own server.