Knowing how people use your application lets you focus your development work on the scenarios that are most important to them, and gain insights into the goals that they find easier or more difficult to achieve. Google Analytics or Azure Application Insights will take you to the next level of analyzing the SharePoint Usage.
In the below example, I am going to show you how to hook up Google Analytics or Azure Application Insights tracker file to track SharePoint Usage in the site collection level using the famous Pnp Provision Engine Template.
Steps to implement
- Extract the PnpCustomAction.zip file and Paste the PnpCustomAction folder on your laptop/server
- Install PnPPowerShellCommands16.msi on your laptop/server (download here – https://github.com/OfficeDev/PnP-PowerShell/tree/master/Binaries). To know more about Pnp Provision Engine click here
- Open the Google Analytics or Azure Application Insights JS action) file and update the script you have copied from
- Upload the JS action) file in your CDN/SharePoint Library. In this example, I have uploaded the file in a document library
- Open the file and update the URL(the place where you have uploaded the file) mentioned in the ScriptBlock attribute under pnp:CustomAction node
- Update the site collection URL in file and execute
- Navigate to different sub-sites under the site collection against where you have executed this script and make sure the tracking data are captured.
Let me know if you have any queries on this.