在具有匿名使用者在 SharePoint Server 中的網站上使用建議和常用項目Use recommendations and popular items on websites with anonymous users in SharePoint Server

摘要:了解如何使用與匿名使用者的 SharePoint Server 2016 與 SharePoint Server 2013 的網站上的 [建議項目和常用項目。Summary: Learn how use Recommended Items and Popular Items on websites with anonymous users in SharePoint Server 2016 and SharePoint Server 2013.

此系列中,在前一篇文章新增及設定 SharePoint Server 中的建議項目和熱門項目網頁組件,說明如何新增並設定建議項目和常用項目網頁組件。本文中您將了解:The previous article in this series, Add and configure the Recommended Items and Popular Items Web Part in SharePoint Server, explained how to add and configure Recommended Items and Popular Items Web Part. In this article you'll learn:

注意

[!附註] 本系列中的範例是根據內部部署的 SharePoint Server 部署。The examples in this series are based on an on-premises SharePoint Server deployment.

啟用流量 cookie 產生唯一的使用者識別碼Enable usage cookies to generate unique user IDs

此系列中的前一篇文章說明如何產生的邀請一些同事建議以"應該模擬產生檢視使用事件的原因。 」按一下 [廠商參與的所有使用者已都登入。每位使用者登入的使用者,當有唯一的使用者識別碼。在事件儲存我們因此可以確認不同的使用者識別碼已記錄的使用事件的檔案。The previous article in this series explained how to generate recommendations by inviting some co-workers to a to a "Why you should simulate the generation of Views usage events." All users who 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 we were therefore able to verify that different user IDs were recorded for the usage events.

Three User IDs

那要如何可以使用事件記錄以唯一的使用者識別碼時所未登入使用者,也就是當它們匿名訪客?回覆是流量 cookie。根據預設,SharePoint Server web 應用程式未啟用流量 cookie,但您可以啟用它們。這些流量 cookie 產生處理流量事件資料時作為使用者識別碼的唯一 GUID。GUID 是可用的 14 天,cookie 的存留期。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 Server 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 14 days, the lifetime of the cookie.

重要

啟用流量 cookie 在具有匿名使用者的網站上時,可能適用當地法律限制。Local legal restrictions might apply when you enable usage cookies on websites that have anonymous users.

若要啟用流量 cookie,請執行下列動作:To enable usage cookies, do the following:

  1. 在管理中心按一下 [管理 web 應用程式]。In Central Administration, click Manage web applications.

    管理 Web 應用程式

  2. 選取包含您的發佈網站的 web 應用程式,然後按一下 [一般設定Select the web application that contains your publishing site, and then click General Settings.

    一般設定

  3. 在 [ Web 應用程式一般設定] 對話方塊的 [流量 Cookie ] 區段中的 [流量 Cookie 狀態] 中按一下 [ *]。In the *Web Application General Settings dialog box, in the Usage Cookie section, for Usage Cookie Status, click On.

    On

  4. 按一下[確定]以儲存變更。Click OK to save your changes.

    若要確認檢視流量事件已正確記錄在我們的 Contoso 網站上,要求兩個同事 Contoso 電子頁面上按一下 [周圍。他們是這兩個匿名使用者。然後啟動搜尋分析和推送到事件存放區 (這所述來啟動搜尋分析和推入事件儲存區的流量事件執行 Microsoft PowerShell 指令碼) 的流量事件。在流量事件的檔案,確認兩個使用者識別碼相關記錄。To verify that the Views usage events were correctly recorded on our Contoso website, ask two colleagues to click around on the Contoso Electronics pages. They are both anonymous users. Then start search analytics, and push the usage events to the Event store (this was explained in Run Microsoft PowerShell scripts to start search analytics and push usage events to the Event store). In the usage event file, verify that two user IDs are recorded.

    兩個匿名使用者識別碼

啟用匿名使用者的使用事件的錄製Enable the recording of a usage event for anonymous users

當您啟用流量 cookie 時,僅檢視使用事件可以匿名使用者的記錄。如此,您可以記錄其他流量事件,例如建議顯示,匿名使用者必須先變更上使用事件的參數值。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.

選項參數會指定是否可以針對匿名使用者記錄使用事件。例如,檢視使用狀況] 之事件選項參數是預設設為AllowAnonymousWrite 。這表示檢視使用事件都可以錄製匿名使用者。The Options parameter specifies whether the usage event can be recorded for anonymous users. For example, for the Views usage event, the Options parameter is by default set to AllowAnonymousWrite . This means that the Views usage event can be recorded for anonymous users.

預設設定檢視

建議顯示流量事件,選項參數是預設設為None 。這表示建議顯示流量事件不會記錄匿名使用者。For the Recommendation Displays usage event, the Options parameter is by default set to None . This means that the Recommendation Displays usage event cannot be recorded for anonymous users.

預設設定建議顯示

若要啟用匿名使用者的流量事件記錄的步驟如下:Here are the steps to enable the recording of a usage event for anonymous users:

  1. 在伺服器上安裝 SharePoint Server,開啟SharePoint 2013 管理命令介面On the server where SharePoint Server is installed, open the SharePoint 2013 Management Shell.

  2. 在 Microsoft PowerShell 命令提示字元處,輸入下列命令:At the Microsoft 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>是的流量事件想要啟用匿名使用者,例如2 ,這是建議顯示流量事件數。<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.

    取得流量事件 2

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

    允許匿名寫入

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

    記錄匿名寫入

啟用之後的建議會顯示建議點選匿名使用者,您必須確認這些流量事件都會加以記錄。因此,一次要求部分繞 Contoso 網站上按一下以匿名使用者的同事。然後啟動搜尋分析和流量事件推送到事件存放區,執行 Microsoft PowerShell 指令碼來啟動搜尋分析和推入事件的流量事件儲存所述。After enabling Recommendations Displays and Recommendations Clicked for anonymous users, you have to verify that these usage events are recorded. So, again ask some colleagues to click around on the Contoso website as anonymous users. Then start search analytics, and push the usage events to the Event store, as explained in Run Microsoft PowerShell scripts to start search analytics and push usage events to the Event store.

Remember, in the Event store, each usage event type is recorded in a separate file. Each file name starts with the EventTypeID. Therefore, a file name that begins with  *1*  contains the  *Views*  usage events. A file name that begins with  *2*  contains the  *Recommendations Displays*  usage events. 

In the Event store, you can verify that three usage event types are logged. Nice!

 ![Three usage events recorded](../media/OTCSP_ThreeUsageEventsRecorded.png)

現在您知道如何設定與您的網站上顯示建議和常用項目。如果您想要更多詳細檢視數目的特定項目或類別,您可以這麼做流量分析報告您目錄中。我們將為您示範如何可以這麼做後續文章中。現在您知道如何設定與您的網站上顯示建議和常用項目。在您要更多詳細檢視數目的特定項目或類別、 尋找流量分析報告在您的目錄。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. We'll show you how you can do that in the next article. Now you know how to configure and display recommendations and popular items on your website. In the you want more details about the number of views for a specific item or category, look in the usage analytics reports on your catalog.

本系列中的下一篇文章Next article in this series

檢視及設定 SharePoint Server 中的流量分析報告View and configure usage analytics reports in SharePoint Server