Issue:

Popularity trends or usage data is not working in any SharePoint 2016 environment. All the search related reports showing the data but no Analytics related data showing in the report. We are getting 0s in every report.

We learned that since SharePoint 2013 Analytics are now part of Search Service Application. The process how analytics works:
  • Search Service Application configure and connect to the web application
  • Usage and Health data collection service application configured on both farms (Search farm and content farm)
  • Search complete the crawl successfully
  • Users perform actions on their sites
  • Now "Microsoft SharePoint Foundation Usage Data Import"  will dump the data in Analytics logs on the local farm as well as update the EventStore at search farm.
  • Usage Analytics process @1am and dump the data in Analytic DB.

Troubleshooting:


We checked following things

  • We have connected to search service farm and Search Service application is connected to the web application
  • Search is actively crawling the content.
  • Make "Microsoft SharePoint Foundation Usage Data Import" timers jobs running on schedule
  • Daily job is on Schedule.
  • Check the Usage Log file if the entries are there. On content farm yes it but on search farm, we are not seeing the entries from the content farm.
  • Check the ULS logs but no clue as we are not familiar with usage related entries
  • Open a ticket with MSFT.
  • Enable the VerboseEx Logging and examine the logs. We found this
  • In the ULS we have seen the referral URL in the ULS logs
  • But following missing Instantiating usage receiver
    •  'Microsoft.Office.Server.Search.Analytics.Internal.AnalyticsCustomRequestUsageReceiver.'
    •  Microsoft.Office.Server.Search.Analytics.Internal.ViewRequestUsageReceiver'.
  • Next, we ran the following PowerShell to get the information about the event receiver.
$aud = Get-SPUsageDefinition | where {$_.Name -like "Analytics*"}
$aud | fl
 

and now run this command.

$prud = Get-SPUsageDefinition | where {$_.Name -like "Page Requests"}
$prud | fl
  • Out put clearly showing us that both Event Receiver disabled.
  • here is our break point:pop6.jpg


Root Cause:

As we have seen in the ULS logs that Event receiver for both usage definition are disabled. I think this is because we do not have the Search service application in the content farm so SharePoint do not enable these event receivers as these required search service application.
 

Resolution:

 
We have to enable the Enable the both Event Receivers, and attache it to Usgae service application in the Content Farm. please follow these steps:
 

Enabling the Event Receivers:


Lets enable the event receivers, We have to run the command in the Content Farm.

Page Requests

Run the below PowerShell in Content farm: for enabling the event receivers: 
$prud = Get-SPUsageDefinition | where {$_.Name -like "Page Requests"}
$prud.EnableReceivers=  $true
$prud.Enabled = $true
$prud.Update()
$aud = Get-SPUsageDefinition | where {$_.Name -like "Page Requests*"}
$aud | fl

For Analytics

  • Run the below PowerShell in Content farm: for enabling the event receivers: 
$aud = Get-SPUsageDefinition | where {$_.Name -like "Analytics*"}
$aud.EnableReceivers=  $true
$aud.Enabled = $true
$aud.Update()
$prud = Get-SPUsageDefinition | where {$_.Name -like "Analytics"}
$prud | fl
 

Attaching Event Receivers:


Page Requests

  • Run the below PowerShell in Content farm to attach the page request receiver:
$prud = Get-SPUsageDefinition | where {$_.Name -like "Page Requests"}
$prud.Receivers.Add("Microsoft.Office.Server.Search.Applications, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c","Microsoft.Office.Server.Search.Analytics.Internal.ViewRequestUsageReceiver")
$prud.EnableReceivers=$true

For Analytics:

  • Run the below PowerShell in Content farm to attach the Analytics receiver:
$aud = Get-SPUsageDefinition | where {$_.Name -like "Analytics*"}
$aud.Receivers.Add("Microsoft.Office.Server.Search.Applications, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c", "Microsoft.Office.Server.Search.Analytics.Internal.AnalyticsCustomRequestUsageReceiver")
$aud.EnableReceivers = $true

Now we wait for 24 hours and everything is working as expected.