If you’re using SharePoint Classic sites, you can setup Matomo Tag Manager by following the instructions in the article Setup Matomo Tag Manager to the classic SharePoint site collections. The solution described in the article involves running this third-party PowerShell script to automatically add the Tag Manager container code to your SharePoint sites.

See also Is Matomo compatible with Microsoft SharePoint Online (O365 Analytics) and/or SharePoint On-Premises?

Important note: The links above contain information and resources that are neither maintained nor endorsed by the Matomo Team. The use of third party extensions is at your own risk.