If it is just to know more about your visitors, then there are plenty of options.
Piwik (now named as Matomo) is a very popular open-source option. I would argue, it is the most popular one out there. If you run into a problem, you will find support out there.
If you use a CDN like CloudFlare, they provide analytics sometimes, like Cloudflare Web Analytics.
If you use a shared web host, most of them support AWStats or something similar, where you can find out more about your visitors.
If you like tinkering with stuff, use an open source option.
If you want a free option, choose an open source option or go with CDN-provided or host-provided options.
If you want to run with minimal fuss, choose one of the popular options.
If you want to write one yourself, pick one from Github, fork and get going. It is not too difficult. I have written one from scratch once and used to use it on my sites, and it wasn't too difficult.
If you make proper discolures in your privacy policy and use our default, strong privacy cookieless settings, you won't need cookie banner and consent form.
Don't need advanced use cases, not interested in monetization. Counter.dev got me because:
- it's simple
- respects users' privacy
- has a pay-what-you-want model
[0]: https://wplytic.com
All other tracking methods is an invasion of privacy.
It's all bots trying to find wordpress exploits that aren't there.