If you already saw the post about setup matomo analytics to Modern SharePoint from any platform but you are still using the classic experience of SharePoint, the SPFx solution cannot be used.

How to implement Matomo Analytics in this case? To do this, you can:

  1. Follow the tutorial provided by the official website of Matomo that consists to edit Master Page: https://matomo.org/faq/how-to-install/faq_34763/. Honestly, I don't recommend this solution for several reasons:
    • Microsoft can push some updates and because you already have edited the master page, you can block these updates and won't benefit from new features
    • Any update of SharePoint released by Microsoft can break your modifications
    • It is risky! If you break Master Page, your final users can not reach any page of the SharePoint site anymore (advice: edit only the site Master page and not the System one. That allows your administrators to keep access to the back office but there will be no analytics available for this kind of pages)
    • Any update needs to deploy/edit each concerned Master Page
    • Edit Master Page is not a Best Practice and not available with the Modern UI anymore
  2. Create custom page layouts
    • You have to edit all native page layouts or remove them
    • Create as many page layouts as your final users need
    • Update all your page layouts on all of your SharePoint sites is a really tricky situation
  3. Add Content Editor or Script Editor on each page
    • Don't forget to add it to each page
    • No web part on the back office pages
    • Users can easily remove it
    • Complicated for your final users and for the maintenance
  4. Use this solution based on SharePoint Custom Actions
    • You do not touch on native elements
    • Implement into your Template, by PowerShell or bash. Users can't change or bypass the script without sufficient rights and knowledge
    • You have to have a script to update massively the Custom Action. You can do it without disturbing your final users
    • Approximately the same behavior that the SPFx extension
    • You can add, remove, update, disable and enable several or only one site collections

Setup Matomo Analytics

I wrote a script that will allow you to easily implement the Analytics tracker script into your SharePoint sites.

Prerequisites

  1. A Matomo (Piwik) server (On-Premises) or instance (Online)
  2. A Matomo Analytics Tracking Site ID: https://developer.matomo.org/guides/tracking-javascript-guide#finding-the-piwik-tracking-code
  3. You will need to install the PnP PowerShell module (I did not create the bash script yet πŸ‘ŽπŸ»)

PowerShell

  1. Download the solution from the repository
  2. Unzip the archive
  3. From your PowerShell terminal, launch the SPMA.ps1 and indicate the credentials to the Windows prompt
.\SPMA.ps1 -siteUrl "https://intranet.mydomain.com/sites/targetSite" -trackingUrl https://matomo.my-domain.com -trackingSiteId "1"

If you cannot execute the PowerShell script, because of security reasons, before unzipping the package, execute the Unblock-File cmdlet.

[note]Note

Other options are available as illustrated into the README.md, that allow you to manage the deployment
[note]Note

The user account that will perform the following actions has to have sufficient permissions on the target sites collection.



Hoping this post will help you πŸ˜‰

You may also be interested in