Enabling A/B testing
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 for more information.
Default cookie level or consent requirements
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 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:
Enabling A/B testing
To configure your website so that it allows A/B testing:
- Open the Settings application in the Xperience administration interface.
- Click the On‑line marketing category in the settings tree.
- Select your Site in the site selector (or enable A/B testing globally).
- Select the Enable A/B testing check box.
- Click Save.
- 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 and custom conversions).
- Make sure activity tracking 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, which are used to evaluate A/B tests.
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)
Additionally, developers need to make the following adjustments on the side of the live site application:
Open your MVC project in Visual Studio.
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 Xperience 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 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(); ... }
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 *@ @Html.Kentico().ABTestLoggerScript()
Open your live site project in Visual Studio.
Edit your application’s startup class (Startup.cs by default).
Enable the A/B testing feature by calling the UseABTesting method of the IFeaturesBuilder delegate passed to the IServiceCollection.AddKentico method within ConfigureServices.
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(); ... }); ... }
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 <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 *@ @Html.Kentico().ABTestLoggerScript()
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.