A/B Testing with Liferay DXP and Optimizely

Hypothesis proven by experiments are the best way to discover customer sentiment. Major sites like are using A/B testing in their day-to-day operations to discover these sentiments.

Within Liferay DXP it is possible to create A/B testing scenario's using Application Display Templates and randomly displaying something like a green or blue submit button and adding Google Analytics event tracking. Another way would be to use the Audience Targeting engine and also track response using Google Analytics.

While we would wish Liferay has everything but the kitchen sink reality is that the platform evolves. Sometimes our customers and users wish for functionality that we may not have out-of-the-box yet and while the feature may be on our roadmap if you need a solution now that isn’t of much help. However, Liferay gives you all the freedom to integrate and enhance the features of the platform. This can be much easier than you might suspect.

To have a more advanced and easier way to perform A/B or multivariate testing within Liferay DXP you can integrate with In this blog post I will describe the steps you must take to get this up and running. 

First of all, you need to create an account with I would recommend watching the video 'Getting started on web optimization' once you are signed up.

Then you will need to copy your custom code snippet, e.g.:

<script src=""></script>

This snippet must be added to all the pages where you need A/B testing. In my case I added it to all pages by using a custom theme. I used the theme generator and modified the portal_normal.ftl

    <title>${the_title} - ${company_name}</title>
    <meta content="initial-scale=1.0, width=device-width" name="viewport" />
    <@liferay_util["include"] page=top_head_include />
    <script src=""></script>

I deployed the theme and applied it to my site, but you can also apply it to specific pages if you like.

From this moment on your site is ready for A/B testing and all you need to do now is define experiments within You can modify text, images or any part of your page. Create one or more variations (so not just A/B) to measure what works best for your site.

Happy testing!

Jan Verweij