Multiple personalization accounts
This topic describes how to connect multiple personalization accounts using scopes, for multisite implementations of Episerver Personalized Search & Navigation.
How it works
EPiServer.Personalization allows a single Commerce installation to connect to more than one Personalization Engine instance, that is, multiple personalization accounts. To support multiple personalization accounts, EPiServer.Personalization supports the concept of scope, see Using Scopes in a Multisite Installation.
This example describes how to connect personalization accounts with scopes.
- An Episerver Commerce site v12.4.1 or higher.
- Quicksilver sample site, v12.4.1 or higher (optional).
- EPiServer.Personalization.Common, v2.0.0 or higher.
- Personalization API base URL, client token, admin token and site.
Scopes are useful for example in scenarios where you have personalization on multiple sites. If you only have one site with personalization features, you can use scopeless settings.
If you need to configure multiple scopes, the scope name must be the site's SiteDefinitionID. To find that value, log into the CMS and go to Admin mode > Config tab > Manage Websites. In Episerver CMS versions 11.5.0 and higher, this value is shown for each site. See Using Scopes in a Multisite Installation.
These are some examples of defining and using scopes.
Settings with no alias suffix are called "scopeless". You can consider all settings in earlier versions of the configuration schema as scopeless.
Scopeless settings are used as a fallback if a requested setting is not defined for a specific scope, meaning that the configuration schema is backwards compatible.
Personalization with specific scope
Example of using personalization with a specific scope to score search results.
public static IQueriedSearch<TSource, FunctionScoreQuery> UsingPersonalization<TSource>(this ISearch<TSource> search, string scope)
Tracking with specific scope
Example of tracking search with a specific scope, only effective if the EPiServer.Find.Personalization package is installed.
public static ISearch<TSource> Track<TSource>(this ISearch<TSource> search, string scope)
You get a default implementation of the scope feature with the EPiServer.Personalization and EPiServer.Find.Personalization packages. This implementation assumes that each CMS site uses one Commerce catalog and one Personalization Engine instance. If this setup fits your needs, set it up using the configuration only. For a more specialized setup, you need to write custom code.
Preference attribute data storage
The default implementation stores preference attribute data in cookies in the same way as earlier versions. If you have a single site using Personalization, you do not need to modify this behavior. To add additional scopes, you probably need to implement your own IPreferenceRepository and modify CUID and SessionID storage behavior. See Using Scopes in a Multisite Installation.
Modifying the default behavior
If your installation differs from what is supported by the default implementation, you can write custom code as described in the following.
Preference attribute data storage
Preference attribute data depends on the CUID and SessionID. This data is created by the Personalization Engine and is only valid for the Personalization Engine instance that created them. So, these values need to be siloed per scope.
The default implementation stores preference attribute data in cookies bound to the current domain. This implementation covers the common scenario where domains are not shared between scopes. To support the sharing of two scopes with a single domain, write custom code.
Another possible scenario is splitting an existing scope in two. In this case, make sure that existing cookie values are not used for the new scope.
To control how cookies are created and read for a scope, replace the default IPreferenceRepository implementation with your custom implementation. You also need to change the default ICookieService implementation used in EPiServer.Personalization.
Last updated: Jun 18, 2020