Product DocsMenu

Customizing the Collected Usage Analytics Data

You can customize the data that the Usage Analytics module collects.

Adding custom data

The DocumentFields parameter needs to be added in the Web.config file (edited in Deploying the On-Premises Usage Analytics Module) to be able to log document metadata into the Usage Analytics database. The DocumentFields value is a comma-separated list of custom fields.

Note: It is recommended to make a backup of the web.config file before editing it.

<coveoEnterpriseSearch>
  <analytics enabled="true" connectionString="myConnectionString" DocumentFields="@myFirstField,@mySecondField" />
</coveoEnterpriseSearch>

Modifying actions before they are saved into the database

The following C# code is an example that adds information to an action before it is saved. The following example, added to the ASPX page, changes the values for UserId, SiteId, and ActionValueMedata (current date and time) before they are saved into the SQL database.

<%@ Import Namespace="Coveo.CES.Web.Search.Analytics" %>
<script language="c#" runat="server"> 
  protected override void OnLoad(EventArgs p_Args)
  {
    this.ReportCustomActionData += delegate(object sender, AnalyticsActionEventArgs args) 
    {
      args.ActionData.UserMetadata.Add("UserId", "test1234567890");
      args.ActionData.SessionMetadata.Add("SiteId", "site #987654321");
      args.ActionData.Values.Add(new ActionValueData("myDate", DateTime.Now));
    }; 
  }
</script>

Creating custom actions

This example is similar to the one shown in Modifying actions before they are saved into the database except that it adds values on custom actions based on your own events that are not in the predefined list of logged actions (see Usage Analytics Database Content).

using Coveo.CES.Web.Search.Analytics;
var values = new List<ActionValueData>() {new ActionValueData("myActionValue", "valueToLog")};
AnalyticsLogging.LogAction(SearchObject, "myAction", ActionValueNames.OutputTypeValues.WEB, values, null);
People who viewed this topic also viewed