Enabling A/B testing

Kentico EMS required

Features described on this page require the Kentico EMS license.

A/B testing allows marketers to create different versions of pages and evaluate them according to the subsequent behavior of the website’s visitors. You can confirm which changes are actually beneficial and use the content that works best for the users who visit your website. The testing process does not interfere with browsing on the website. Visitors do not need to give any feedback manually.

See A/B testing pages for more information.

The A/B testing functionality uses cookies to keep track of the page variant displayed to individual visitors. For A/B testing to work correctly for all visitors, your site’s Default cookie level setting must be set to Visitor or All. Otherwise the testing only works for visitors who give consent and increase their cookie level.

For more information, see:

Enabling A/B testing

To configure your website so that it allows A/B testing:

  1. Open the Settings application in the Kentico administration interface.
  2. Click the On‑line marketing category in the settings tree.
  3. Select your Site in the site selector (or enable A/B testing globally).
  4. Select the Enable A/B testing check box.
  5. Click Save.

Permission requirements

To work with A/B tests in the Pages and A/B tests applications, users need to have permissions for:

Additionally, developers need to make the following adjustments on the side of the MVC live site application:

  1. Open your MVC project in Visual Studio.

  2. Enable the A/B testing feature by calling the UseABTesting method of the ApplicationBuilder instance.

    • Enable the feature at the start of your application’s life cycle, for example in the Application_Start method of your project’s Global.asax file.

      MVC projects created by the installer contain the ApplicationConfig class, whose RegisterFeatures method is called in the Application_Start method by default. You can use this class to encapsulate all of your ApplicationBuilder code (enabling and configuring of Kentico MVC features).

      Note: The feature must be enabled before you register routes into the application’s RouteTable. The Kentico().MapRoutes() method adds required routes based on the set of enabled features.

        using Kentico.OnlineMarketing.Web.Mvc;
        using Kentico.Web.Mvc;
        protected void Application_Start()
            // Gets the ApplicationBuilder instance
            // Allows you to enable and configure selected Kentico MVC integration features
            ApplicationBuilder builder = ApplicationBuilder.Current;
            // Enables the A/B testing feature, which provides system routes used to log A/B testing data and conversions
  3. Register A/B testing logging scripts onto all pages by calling the ABTestLoggerScript extension method in views.

    • Call the method in your MVC website’s main layout (and any other used layouts) to ensure that the scripts are available for every page.
    • The logging scripts run asynchronously, so we recommend adding them at the end of the <head> tag in the page code.
Required namespaces

@using Kentico.OnlineMarketing.Web.Mvc
@using Kentico.Web.Mvc

    @* Registers scripts that ensure logging of analytics data for A/B tests *@

Enabling the UseABTesting feature ensures that the system registers routes that process A/B testing logging requests. The logging itself (conversions and other related data) is performed by client scripts added to pages by the ABTestLoggerScript extension method.

The site now logs conversions and other analytics data for A/B tests. For example, Page visit conversions are logged when a visitor views a page and the following conditions are fulfilled:

  • The visitor has previously viewed a page with a running A/B test.
  • The given A/B test is configured to track a conversion of the Page visit type, and the conversion’s Page URL value matches the current page.

Conversion tracking

A/B tests evaluate page variants by tracking the actions of visitors who view the tested page. These actions are known as conversions.

By default, the following types of actions can be tracked as conversions (no further code adjustments are required):

  • Form submission
  • Newsletter subscription
  • Page visit
  • Product added to shopping cart
  • Purchase
  • Purchase of a specific product
  • User registration

If you wish to track other types of visitor actions as conversions, developers can register custom conversion types and log conversions from any location within the site’s code. See Logging custom A/B testing conversions.