Setup Matomo Analytics to SharePoint Online

Matomo is one of the best alternative (in terms of ease of implementation and basic features, not in terms of advanced features) in Europe for GDRP compliant analytics solution 🚀.

Matomo comes in two flavours :

  • Cloud Hosting (prices here – with commercial plugins included)
  • Self-Hosted with manuel installation (open source/free of licence cost – no commercial plugins included)

Once you have your Matomo environment ready, take the train :

Prerequisites

  1. Create your website in Matomo and get your « tracking site ID »
  2. Check your account have the right permission to add a solution to your Tenant App Catalog (if you deploy to your tenant app catalog => https://docs.microsoft.com/en-us/sharepoint/use-app-catalog) or in your Site collection App Catalog (if you deploy your tracking custom action to a site collection, or on a per site collection basis => https://docs.microsoft.com/en-us/sharepoint/dev/general-development/site-collection-app-catalog)
  3. Install Pnp PowerShell by following these steps : Installing PnP PowerShell | PnP PowerShell
  4. Download the addin and the setup script zip archive here (lastest is v1.1.0 now) : Releases · Microsoft SharePoint / SPFx / Matomo Analytics · GitLab (lsonline.fr). Feel freee to modify the source to add whatever features you need (ex : custom dimensions, …).

Add and setup the Matomo SPfx custom action

  1. Open a PowerShell console prompt
  2. Connect to your tenant with : Connect-PnPOnline -Url https://<your_tenant_name>.sharepoint.com -Interactive
    • Interactive parameter is for MFA authentication. If you don’t use MFA, omit this parameter
  3. Unzip the zip archive previously downloaded in the prerequisites
  4. Execute the following command at the root of the unzipped folder : .\setup.ps1 -siteUrl https://<your-tenant_name>.sharepoint.com -trackingUrl https://matomo.mydomain.com -trackingSiteId ‘<my_tracking_site_id>’ -tenantSolutionDeployment
    • In this case, I deployed on the entire tenant (all site collections). You can omit this parameter to deploy only on a site collection.
  5. Crack your favorite webbrowser, connect to your Matomo instance, your SharePoint is already recording user actions.

Happy analytics 👍😎