Coveo User Context

Warning
Legacy feature

This article pertains to the Coveo Hive framework which is now in maintenance mode.

Choose one of Coveo’s more modern, lightweight, and responsive libraries for any future search interface development. See the search interface Implementation guide for more details.

Coveo for Sitecore Specific Rendering Allows adding user context to page view analytics in Sitecore article items. In search interfaces, it adds user context to Search API and query suggestion calls.

User context refines search results as well as Coveo Machine Learning (Coveo ML) content recommendations and query suggestions.

Usage notes

Insertion location

Coveo Hive

The Coveo User Context rendering is an Allowed Control in the following placeholder(s): UI Resources

Example insertion sequence for the Coveo User Context rendering.

Coveo Hive SXA

Coveo for Sitecore SXA rendering insertion locations are not limited by placeholder Allowed Controls. The Coveo User Context rendering may therefore be inserted throughout the partial design, whether in Coveo for Sitecore or Sitecore placeholders.

Example insertion sequence for the Coveo User Context rendering.

Data source options

Option name Description

Use anonymity in context

Specifies whether to add an isAnonymous key and its value to the user context, indicating whether the user is anonymous.

Use country in context

Specifies whether to add the visitor current country to the user context.

Use device in context

Specifies whether to add the visitor current device to the user context.

Use profile cards in context

Used to specify the profile cards you want to add to the user context.

Enable context pipeline

Specifies whether to run the coveoUserContext pipeline when computing the context (see UserContextPipeline).

Custom context

Static key and value pairs to add to the user context.

DOM unique ID

Randomly generated HTML element ID.

Sample Generated HTML and Corresponding Output

In the following example, you have inserted the Coveo User Context rendering in a search page and enabled the Use anonymity in context, Use country in context, and Use device in context data source options.

A logged New Zealander visits your search page.

Generated HTML:

<script type="text/javascript" src="/Coveo/Hive/js/CoveoForSitecoreUserContext.js"></script>
<script>
    if (!!window.CoveoForSitecoreUserContext) {
        CoveoForSitecoreUserContext.handler.initializeContext({"device":"Default",
        "isAnonymous":"false","country":"NZ"});
    }
</script>

Generated query suggestion call:

Query Suggestions call with user context | Coveo for Sitecore 5