Or even if you don't want to use your web server's logs for this purpose for whatever reason, this is quite trivial to implement in JS yourself. No need for GA and other bloated analytics frameworks.
If you could trivially implement Matomo (a project that has been developing over 16 years) in JS, please open source it. Would love to get rid of the PHP in our stack.