Setup Matomo Analytics to the classic SharePoint site collections
2 min read
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:
- 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
- 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
- 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
- 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
- A Matomo (Piwik) server (On-Premises) or instance (Online)
- A Matomo Analytics Tracking Site ID: https://developer.matomo.org/guides/tracking-javascript-guide#finding-the-piwik-tracking-code
- You will need to install the PnP PowerShell module (I did not create the bash script yet 🙄)
PowerShell
- Download the solution from the repository
- Unzip the archive
- From your PowerShell terminal, launch the
SPMA.ps1and 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
A solution to setup the Matomo Tag Manager script into your SharePoint site collections with classic experience
2 min read
Security
Modernizing Access Governance: Why It’s Time to Move Beyond "Everyone Except External Users" (EEEU)
Everyone Except External Users (EEEU) is one of the most misunderstood identities in Microsoft 365. In this post, I explain why hiding EEEU doesn’t disable it, where Microsoft still uses it internally, and how to modernize your governance with dynamic groups.
4 min read
Power Automate connections often break silently. Here’s how you can built an agent to monitor and log their health in SharePoint.
5 min read
Warn final users about the SharePoint sites collections that allow external sharing thanks to SharePoint Framework
3 min read