HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Disable personalized content

Describes how you can disable personalization, such as Visitor Groups, within Optimizely Content Management System (CMS). It is enabled by default.

📘

Note

This content applies to Optimizely Content Management System (CMS) versions 11.8.0 and higher.

When personalization is enabled and a requested content item uses visitor group personalization, then the visitor is evaluated against the used visitor groups and visitor groups criteria. The content displayed to the visitor is selected depending on which visitor groups match the request. Depending on the used criteria, this can cause tracking data to be stored in cookies and/or session state.

When personalization is disabled, no matching occurs and the visitor is not considered to be part of any visitor group. Instead, the visitor is displayed the "fallback content", if that is defined on the personalized content. When personalization is disabled, no state is stored in cookies or for the visitors' sessions.

IPersonalizationEvaluator

There is an interface that can be implemented to control whether personalization should occur or not. The interface is specified as:

/// <summary>
    /// Signature for a component that determine if personalization should be performed or not for the current request
    /// </summary>
    /// <remarks>
    /// Registration of an implementation is done by register the implemenation in IOC container
    /// </remarks>
    public interface IPersonalizationEvaluator
      {
        /// <summary>
        /// Determines if current request should be personalized or not
        /// </summary>
        bool Personalize();
      }

Examples

CMS includes an implementation that checks for presence of a Do Not Track header. If the header is present, no personalization is done for the request and no cookies are stored. It can be registered in ConfigureServices in the startup, as in this example:

public class Startup
    {
         public void ConfigureServices(IServiceCollection services)
         {
            services.AddTransient<IPersonalizationEvaluator, DoNotTrackPersonalizationEvaluator>();
         }
    }

Another example could be to check for existence of a certain cookie which specifies that the visitor has agreed that visitor group personalization could occur. In that case, the site could have a field where the visitor can enable  personalization. When the visitor selects that field, a cookie is added for the visitor. Such an example could look like:

[ServiceConfiguration(typeof(IPersonalizationEvaluator), IncludeServiceAccessor = false)]
    public class CookiePersonalizationEvaluator : IPersonalizationEvaluator
      {
        public const string PersonalizeCookieKey = "Personalize";
        private readonly ServiceAccessor<HttpRequestBase> _requestaccessor;
        public CookiePersonalizationEvaluator(ServiceAccessor<HttpRequestBase> requestAccessor)
          {
            _requestaccessor = requestAccessor;
          }
        public bool Personalize() => _requestaccessor()?.Cookies[PersonalizeCookieKey] != null;
      }

Check if personalization is enabled

The IAggregatedPersonalizationEvaluator component can be used to check if personalization is enabled for a request or not. The signature is similar to IPersonalizationEvaluator and it returns an aggregated result from all registered IPersonalizationEvaluator instances. If any personalization evaluator states that personalization should be disabled, then the aggregated evaluator states that no personalization should occur.