Partager via


Use recommendations and popular items on websites with anonymous users in SharePoint Server 2013

This is a blog post in the series “How to display Recommendations and Popular items on a website”. In the previous post, I showed you how to add and configure the Recommended Items and Popular Items Web Part. In this blog post:

Note: The examples in this blog series are based on an on-premises installation.

Enable usage cookies to generate unique user IDs
In an earlier blog post I described how I arranged a “click party” to generate usage events. All users that participated in the “click party” were logged in. When users are logged in, each user has a unique user ID. In the event store file I was therefore able to verify that different user IDs were recorded for the usage events.

Three different user IDs

So how can usage events be recorded with a unique user ID when users are not logged in, that is, when they’re anonymous visitors? The answer is usage cookies. By default, usage cookies are not enabled for a SharePoint web application, but you can enable them. These usage cookies generate a unique GUID that is used as a user ID when usage event data is processed. The GUID is available for the lifetime of the cookie. The lifetime of the cookie is 14 days.

IMPORTANT: Local legal restrictions might apply when you enable usage cookies on websites that have anonymous users.

To enable usage cookies, do the following:

1.  In Central Administration, click Manage web applications.

Manage web applications

2. Select the web application that contains your publishing site, and click General Settings.

General Settings

3.  In the Web Application General Settings dialog box, in the Usage Cookie section, for Usage Cookie Status, click On.

Usage Cookie Status On

4.  Click OK to save your changes.

To verify that the Views usage events were correctly recorded on my Contoso website, I asked two colleagues to click around on my Contoso Electronics website. They were both anonymous users. I then started search analytics, and pushed the usage events to the Event store (I showed you how to do this in an earlier blog. In the usage event file, I verified that two different user IDs had been recorded.

Two anonymous users

Enable the recording of a usage event for anonymous users
When you enable usage cookies, only the Views usage event can be recorded for anonymous users. So, before you can record other usage events, for example Recommendation Displays, for anonymous users, you have to change a parameter value on the usage event.

The Options parameter specifies if the usage event can be recorded for anonymous users. For example, for the Views usage event, the Options parameter is set to AllowAnonymousWrite by default.  This means that the Views usage event can be recorded for anonymous users.

Default Options parameter for Views usage event

For the Recommendation Displays usage event, the Options parameter is set to None by default.  This means that the Recommendation Displays usage event can’t be recorded for anonymous users.

Default Options parameter for Recommendation Display usage event

To enable the recording of a usage event for anonymous users, do the following:

1.  On the server where SharePoint Server 2013 is installed, open the SharePoint 2013 Management Shell.
2.  At the Windows PowerShell command prompt, type the following commands:

# View the EventTypeId’s for all usage events:
$SSP = Get-SPEnterpriseSearchServiceApplicationProxy
$SSP.GetAnalyticsEventTypeDefinitions([Guid]::Empty, 3) | ft

# Get a usage event:
$tenantConfig = $SSP.GetAnalyticsTenantConfiguration([Guid]::Empty)
$event = $tenantConfig.EventTypeDefinitions | where-object { $_.EventTypeId -eq <EventTypeId> }

<EventTypeID> is the number of the usage event that you want to enable for anonymous users, for example 2, which is the Recommendation Displays usage event.

Get usage event 2

# Enable the recording of a usage event for anonymous users:
$event.Options = [Microsoft.Office.Server.Search.Analytics.EventOptions]::AllowAnonymousWrite
$tenantConfig.Update($SSP)

Enable recording for usage event 2

# Verify that the recording of a usage event for anonymous users has been enabled:
$event

Confirm changed Options parameter

After I enabled Recommendations Displays and Recommendations Clicked for anonymous users, I wanted to verify that these usage events were recorded. So, I again asked two colleagues to click around on my Contoso website. They were both anonymous users. I then started search analytics, and pushed the usage events to the Event store (I showed you how to do this in an earlier blog).

Remember, in the Event store, each usage event type will be recorded in a separate file. Each file name starts with the EventTypeID, so a file name that starts with 1 contains the Views usage events. A file name that starts with 2 contains the Recommendations Displays usage events etc.

In the Event store, I verified that three usage event types were logged. Nice!

Three usage event type files

So now you know how to configure and display recommendations and popular items on your website. If you want more details about the number of views for a specific item or category, you can do this by looking in the usage analytics reports on your catalog.  I’ll show you how you can do that in the next blog.

Next blog post in this series
View and configure usage analytics reports

Comments

  • Anonymous
    January 01, 2003
    nice post.. true knowledge share
  • Anonymous
    January 01, 2003
    This is great stuff. Many customers have been asking about this. Keep it coming!
  • Anonymous
    January 01, 2003
    Hi KK,

    No, this is not possible.

    Bella
  • Anonymous
    November 05, 2014
    Hi Bella,

    Great stuff. Is it possible to show the most popular items based on the current logged in user?

    Thanks
  • Anonymous
    November 07, 2014
    Thanks Bella, Is it possible to show the recently viewed items with content search web part based on the currently logged in user?