Here is how I replaced Google Analytics with Piwik/Matomo for a locally hosted privacy-focused open source analytics solution
Read the full article here: https://fearby.com/article/replacing-google-analytics-with-piwik-matomo-for-a-locally-hosted-privacy-focused-open-source-analytics-solution/