How to Make Usage Analytics Work in SharePoint 2016

In this post I’m going to show you how to fix an issue in SharePoint 2016 that prevents usage reports from being correctly updated.

Scenario

We have a SharePoint 2016 site and we need to show users the usage reports.

Problem

The obvious solution would be to use the out of the box SharePoint 2016 Excel usage reports to do that… Unfortunately when we open them we always find all zeros, no matter how many users have interacted with the site and how many documents have been opened.

UsageReportAllZeros

Although we have correctly enabled Usage and Health Data Collection for the right events in Central Administration nothing happens.

Solution

After some research we found that in our fresh new installation of SharePoint 2016 the usage event receivers assemblies were wrong, version 15.0.0.0 instead of version 16.0.0.0.

A really tricky bug that fortunately in our case was successfully fixed by a few Powershell commands and some patience to wait data to be collected and reports to be updated.

Steps

1. Get Usage Analytics Event Receivers

Run the SharePoint 2016 Management Shell as Administrator and run the following Powershell commands to get the “AnalyticsCustomRequestUsageReceiver” and the “ViewRequestUsageReceiver” event receivers.

#Get AnalyticsCustomRequestUsageReceiver event receiver
$ad = Get-SPUsageDefinition | where {$_.Name -like "Analytics*"}
$vru = $ad.Receivers
$vru
#Get AnalyticsCustomRequestUsageReceiver event receiver
$pd = Get-SPUsageDefinition | where {$_.Name -like "Page Requests"}
$pru = $pd.Receivers
$pru

2. Check Usage Analytics Event Receivers Assembly Version

Once you get the event receivers, check for each one that the “ReceiverAssembly” property contains the correct assembly version.

For a SharePoint 2016 environment the correct assembly version must be 16.0.0.0 as shown in the picture below.

UsageEventReceiver

3. Delete the Wrong Event Receivers

If you are in a SharePoint 2016 environment and the event receivers assembly version is not 16.0.0.0 (for example it is 15.0.0.0) you must delete them executing the following Poweshell commands.

#If the receivers assembly is wrong, delete them using the script below
$vru.Delete()
$pru.Delete()

4. Recreate the correct Event Receivers

Now we need to recreate the correct event receivers (assembly version 16.0.0.0) executing the following commands.

#Create the correct event receivers
$ad.Receivers.Add("Microsoft.Office.Server.Search.Analytics.Internal.AnalyticsCustomRequestUsageReceiver")
$pd.Receivers.Add("Microsoft.Office.Server.Search.Analytics.Internal.ViewRequestUsageReceiver")

5. Run Usage Analysis and Import

Finally, we need to start the usage analysis and import as described below.

#Start usage analysis
$a = Get-SPTimerJob -Type Microsoft.Office.Server.Search.Analytics.AnalyticsJobDefinition
$sa = $a.GetAnalysis("Microsoft.Office.Server.Search.Analytics.SearchAnalyticsJob")
$sa.StartAnalysis()
#Get Analysis info. Make sure to wait for 15 minutes as this will allow to complete the timer job properly
$sa.GetAnalysisInfo()
#Start the usage log file import timer job
$tj = Get-SPTimerJob -Identity ("job-usage-log-file-import")
$tj.RunNow()

Conclusion

Having done all the previous steps, we now need only to let the timer job “Microsoft SharePoint Foundation Usage Data Processing” complete as per its schedule (this will not work if you run it manually).

After that, we should be able to view the usage report data correctly updated.

References

Rumi’s Point

Microsoft

 

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s