Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Activate widgets

Describes how to activate widgets and website components used to present personalized product recommendations from Optimizely Commerce Connect.

Optimizely Product Recommendations defines two key concepts:

When an environment is set up, it has the following Commerce Connect-specific widgets. Widgets are configured for only a subset of the available tracking types — see TrackingTypes in the Commerce Connect APIs and libraries for the full list.

Default Commerce Connect widget configuration in the Recommendations portal, showing widgets configured for five tracking types

In a new environment, all widgets are inactive. Before you can track and receive recommendations, activate them with the WidgetService in EPiServer.Personalization.Commerce.

See SiteInitialization.cs in the Quicksilver sample site for a working example. The following snippet shows how to enumerate the widgets returned by WidgetService and activate each one:

var widgetService = context.Locate.Advanced.GetInstance<WidgetService>();
var response = widgetService.GetWidgets();

foreach (var widget in response.EpiPerPage.Pages.SelectMany(x => x.Widgets))
{
    widget.Active = true;
    widgetService.UpdateWidget(widget);
}