---
title: Enabling A/B testing
related:
  - https://docs.kentico.com/13/on-line-marketing-features/managing-your-on-line-marketing-features/a-b-testing-pages.md
  - https://docs.kentico.com/13/on-line-marketing-features/configuring-and-customizing-your-on-line-marketing-features/enabling-a-b-testing/logging-custom-a-b-testing-conversions.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

> **Info:** **Enterprise license required**
>
> Features described on this page require the **Kentico Xperience Enterprise** 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](https://docs.kentico.com/13/on-line-marketing-features/managing-your-on-line-marketing-features/a-b-testing-pages.md) for more information.

## Default cookie level or consent requirements

The A/B testing functionality uses [cookies](https://en.wikipedia.org/wiki/HTTP_cookie) 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 visitors who do not accept _Visitor_ or _All_ cookies, the behavior depends on your site's default cookie level. If the default level is _Essential_, the system at least tracks A/B testing page variants to keep content consistent, but does not log any conversions. If the default level is _System_, no A/B testing cookies are allowed and each view of a tested page displays a randomly selected variant.

To learn more about cookies and consents in Xperience, see:

- [Working with cookies](https://docs.kentico.com/13/developing-websites/working-with-cookies.md)
- [Working with consents](https://docs.kentico.com/13/configuring-xperience/data-protection/gdpr-compliance/working-with-consents.md)

## Enabling A/B testing

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

1. Open the **Settings** application in the Xperience 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**.
6. Navigate to the **On-line marketing → Web analytics** category and make sure the **Enable web analytics** setting is selected.
   - Analytics are required to log conversions (both the [default conversion types](#conversion-tracking) and [custom conversions](https://docs.kentico.com/13/on-line-marketing-features/configuring-and-customizing-your-on-line-marketing-features/enabling-a-b-testing/logging-custom-a-b-testing-conversions.md)).
7. Make sure [activity tracking](https://docs.kentico.com/13/on-line-marketing-features/configuring-and-customizing-your-on-line-marketing-features/configuring-activities/enabling-activity-tracking.md) is enabled (i.e., the **On-line marketing → Enable on-line marketing** setting and the settings in the **On-line marketing → Contact management → Activities** category).
   - Activity tracking is required to log the [default conversion types](#conversion-tracking), which are used to evaluate A/B tests.

> **Info:** **Permission requirements**
>
> To work with A/B tests in the _Pages_ and _A/B tests_ applications, users need to have permissions for:
>
> - The **A/B testing** module (_Read_ and/or _Manage_)
> - Viewing and editing of the related pages (see [Configuring page permissions](https://docs.kentico.com/13/managing-users/configuring-permissions/configuring-page-permissions.md))

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

<!-- dev-model:mvc start -->

**MVC 5 development model.** Applies only when building with ASP.NET MVC 5. If this page also covers ASP.NET Core, that version is in its own block.

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.

     > **Info:** MVC projects created by the [installer](https://docs.kentico.com/13/installation/installing-xperience.md) 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 Xperience MVC features).

     > **Note:** **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.

     ```csharp

     using Kentico.OnlineMarketing.Web.Mvc;
     using Kentico.Web.Mvc;

     ...

     protected void Application_Start()
     {
         ...

         // Gets the ApplicationBuilder instance
         // Allows you to enable and configure selected Xperience 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
         builder.UseABTesting();

         ...
     }

     ```
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 __ tag in the page code.

   ```csharp title="Required namespaces"

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

   ```

   ```csharp

       @* Registers scripts that ensure logging of analytics data for A/B tests *@
       @Html.Kentico().ABTestLoggerScript()


   ```

<!-- dev-model:mvc end -->

<!-- dev-model:core start -->

**ASP.NET Core development model.** Applies only when building with ASP.NET Core. If this page also covers MVC 5, that version is in its own block.

1. Open your live site project in Visual Studio.
2. Edit your application's startup class (**Startup.cs** by default).
3. [Enable](https://docs.kentico.com/13/developing-websites/developing-xperience-applications-using-asp-net-core/starting-with-asp-net-core-development/enabling-xperience-features-in-asp-net-core-applications.md) the A/B testing feature by calling the **UseABTesting** method of the _IFeaturesBuilder_ delegate passed to the _IServiceCollection.AddKentico_ method within _ConfigureServices_.

   ```csharp

   using Kentico.OnlineMarketing.Web.Mvc;
   using Kentico.Web.Mvc;

   ...

   public void ConfigureServices(IServiceCollection services)
   {
       ...
       // Enables and configures Xperience features
       services.AddKentico(features =>
       {
           // Enables the A/B testing feature, which provides system routes used to log A/B testing data and conversions 
           features.UseABTesting();
           ... 
       });

       ...
   }

   ```
4. Register A/B testing logging scripts onto all pages by calling the **ABTestLoggerScript** extension method in views.

   - Call the method in your 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 __ tag in the page code.

   ```csharp title="Required namespaces"

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

   ```

   ```csharp

       @* Registers scripts that ensure logging of analytics data for A/B tests *@
       @Html.Kentico().ABTestLoggerScript()


   ```

<!-- dev-model:core end -->

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](https://docs.kentico.com/13/on-line-marketing-features/configuring-and-customizing-your-on-line-marketing-features/enabling-a-b-testing/logging-custom-a-b-testing-conversions.md).
