WCM tip #12: Recommendation events are not tracked for anonymous users

When working with recommendations SharePoint 2013 Search records analytics events. Unfortunately those events are not being recorded for anonymous users.

One of the new web content management capabilities that SharePoint 2013 offers are content recommendations. With content recommendations SharePoint 2013 tracks the usage of content in your website and generates content recommendations. By using content recommendations on your website you can expand the reach of the content on your website. The great thing about search-driven content recommendations is that they are generated automatically and don’t require any editorial effort.

When working with recommendations SharePoint records analytics events such as which recommendations have been displayed and which of them have actually been used. This information can help you optimize the relevance of search results in your website. Unfortunately, by default, SharePoint 2013 doesn’t track recommendation events for anonymous users. You can enable gathering recommendation events for anonymous users using the following PowerShell snippet:

$SSP = Get-SPEnterpriseSearchServiceApplicationProxy
$SSP.GetAnalyticsEventTypeDefinitions([Guid]::Empty, 3)

$tenantConfig = $SSP.GetAnalyticsTenantConfiguration([Guid]::Empty)
$recommendationView = $tenantConfig.EventTypeDefinitions | ? { $_.EventTypeId -eq 2 }
$recommendationClick = $tenantConfig.EventTypeDefinitions | ? { $_.EventTypeId -eq 3 }

$recommendationView.Options = [Microsoft.Office.Server.Search.Analytics.EventOptions]::AllowAnonymousWrite
$recommendationClick.Options = [Microsoft.Office.Server.Search.Analytics.EventOptions]::AllowAnonymousWrite