HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Install and configure the native integration package

Describes how to install and configure the native integration for Optimizely Commerce Connect.

The native integration provides the product-specific setup when implementing recommendations for Optimizely solutions.

Concepts

Scope

A scope is a context in which tracking and catalog export occurs. A scope contains an instance of an Optimizely Product Recommendations engine and one or more websites communicating with that instance. Scopes are mutually exclusive and never nested; a tracking action occurs only in a single scope. Recommendations for products belonging to a specific scope are not given for tracking actions occurring in another scope.

Alias

A scope alias (referred to as alias) is a shorthand version of the scope's name. Aliases are used as suffixes to appSettings key attribute values. The purpose of an alias is to improve the readability of configuration settings. Aliases are used in configuration settings only; they are not used in the API.

Scopeless

Settings that do not use an alias suffix are called scopeless. In earlier versions of the configuration schema, all settings are scopeless. Scopeless settings are used as a fallback if a requested setting is not defined for a specific scope. This makes the new configuration schema backward-compatible.

If asked for a valid setting for scope X, and scope X is not defined in the configuration file, the internal configuration class falls back to the corresponding scopeless setting.

Install

The native integration package is available through the Episerver NuGet feed. See also Install and configure recommendations.

Use the TrackingOptions class to enable tracking using appsetting.json file, or a startup class. Below is an example using appsettings.json.

{
      "EPiServer": {
        "Tracking": {
          "TrackingOptions": {
            "TrackingEnabled": true
          }
        }
      }
    }

After installing it, you must modify the configuration to include settings for your Product Recommendations environment, which reads its configuration from the PersonalizationOptions class. You can use appsettings.json file to configure options.

Example

{
      "EPiServer": {
        "Personalization": {
          "PersonalizationOptions": {
            "BaseApiUrl": "https://defaultbaseurl.com",
            "Site": "defaultsite",
            "ClientToken": "defaultclienttoken",
            "AdminToken": "defaultadmin",
            "Channel": "test",
            "RequestTimeout": 30,
            "TrackingMode": "ClientSide",
            "SkipUserHostTracking": true,
            "UsePseudonymousUserId": true,
            "FeedCatalogName": "Test",
            "FeedSkipProductLevel": true,
            "Scopes": [
              {
                "AdminToken": "scopeadmin",
                "BaseApiUrl": "https://scopebaseurl.com",
                "ClientToken": "scopeclienttoken",
                "Site": "scopesite",
                "Channel": "scopetest",
                "FeedCatalogName": "ScopeTest",
                "FeedSkipProductLevel": false,
                "ScopeId": "scopeid",
                "Name": "Scope Test"
              }
            ] 
          }
        }
      }
    }

The options described in the following can be used.

Recommendation keys

KeyDescription
BaseApiUrl  The URL of the Episerver Product Recommendations environment to use. This should only contain the protocol and host name. Note: Never use UAT endpoints in production for this key.
Site  The site name used to identify requests to the tracking server.
ClientToken  The token used to authenticate tracking requests to the REST API.
AdminToken  The token used to authenticate admin requests to the REST API.
RequestTimeout  [Optional] Timeout for the REST calls. The default value is 30 seconds.
TrackingMode [Optional] The tracking mode to use. Acceptable values are ServerSide and ClientSide.
The default value is ServerSide.
To use the client side (JavaScript) tracking APIs, set the value to ClientSide.
SkipUserHostTracking[Optional] Lets you exclude user IP address from tracking data. Set to True to omit IP address from tracking, which may reduce recommendation accuracy. Default value is False.
UsePseudonymousUserId[Optional] Controls whether the pseudonymous user identifier is used instead of user email address in  tracking data. Set to True to omit email address from tracking and use Contact Id instead. Default value is False.
CatalogFeedBatchSize  [Optional] The number of products processed in one batch when the product feed is generated. A higher value can be faster but puts more pressure on the memory. The default value is 50.
FeedCatalogName  [Optional] Select the catalog used to generate the product feed if you have multiple catalogs. If this value is not set, the first catalog is used.
Note: This property will be removed when Product feed support for multiple catalogs is added.

The export function has a few settings in addition to those above. Apply them via code on the default CatalogFeedSettings instance.

var catalogFeedSettings = ServiceLocator.Current.GetInstance<CatalogFeedSettings>(); 
    catalogFeedSettings.DescriptionPropertyName = "...";
PropertyDescription
ExcludedAttributes  Names of product properties to exclude from the catalog feed.
DescriptionPropertyName  The product feed requires each product to have a description. Set this to a property name you want to use as description. Default value is Description.
AssetGroupName  The first asset (ordered by SortOrder) in this group is used for the item's image link. The default value is default.

📘

Note

Differences between the authentication mechanism of EPiServer.ServiceAPI and EPiServer.Personalization.Commerce may lead to the incorrect functioning of user change tracking or catalog feed download. To avoid these problems, you should install EPiServer.ServiceAPI in a separate application.