- Upload this file to your SharePoint Root Site Collection and place it in the Style Library (Why? Regularly I use this lib as a on-premises CDN)
- Make sure the file is accessible
- Create a Script Link in the Site Collection you want to track.
For step 3 You can use the following PowerShell code to add a script link to your site collection:
With this setting you can track a user and gain basic insights about his flow through your website. The data you are gaining by now is very basic and there are some SharePoint only specialties:
Minimal Download Strategy (MDS)
In cases that you want to track a SharePoint Site with Minimal Download Strategy enabled, you will need to register your script with MDS. This means you will have change the anonymous code to something with a defined entry point.
Enterprise Search Center
Sometimes it is fun and very interesting to gain deeper insights about the users search behavior.
What’s the problem with Piwik and the SharePoint Search: In case you update your SharePoint Search keyword, Piwik yon’t be able to log information about your new search Keyword.
The default URL for a SharePoint result site looks like that: …/results.apsx?k=YourKeyWord
When you change YourKeyWord to YourNewKeyWord, your URL will look like this: ../results.aspx?k=YourKeyWord#k=YourNewKeyWord
Piwik will not notice this event and even if you press refresh, it will get the wrong key word (YourKeyWord and not YourNewKeyWord). To overcome this issue you will need to extend the prior script to:
- Start tracking when the hash changes
- Call a other Piwik tracking method to provide additional information about the search key word, and maybe the search result source used.
This script could look like this:
This script makes usage of the trackSiteSearch function, that allows you to provide additional insights about the search key word, the category and the number of results. From my experience there is an issue with the timing, when the count of results will be refreshed. So in this case false looks like the best option.