Skip to main content

Perform A/B Testing in LoyJoy

What This Solution Will Do for You

This article is right for you if you want to run an A/B test with two (or more) different chats within the same agent.

What You Need for This Solution to Work

This article offers two different options. Either control over the URL parameters of the link your users open your website with. Or simply a LoyJoy agent that you can modify.

There Are Two Options for A/B Testing

  • Switching agents based on freely defined URL parameters
  • Switching inside one agent base on a random 50/50 split in LoyJoy

Switching Agents With URL Parameters

Let's say your website has the URL https://www.example.org. Just use two or more parameters that you can access in LoyJoy like this:

https://www.example.org?loyjoy-myparam=value1

and

https://www.example.org?loyjoy-myparam=value2

It is required that the param name starts with loyjoy- so that LoyJoy can identify it. After the loyjoy- you can add a custom name for your parameter. If you need more than one parameter, connect the parameters with an &, for example https://www.example.org?loyjoy-myparam=value1&my-tracking=trackig-code.

Inside LoyJoy, we can access this parameter and, for example, make an automatic jump based on it:

LoyJoy A/B testing with URL params

Here, we trigger an automatic jump, if the given parameter has the value true. This jump can lead to a specific position in the process or to another process altogether.

Switching Based on Random 50/50 Split in LoyJoy

For this approach we need to set a random variable at the beginning of the agent that sets up the 50/50 split. As source for the variable pick the randomInt function from the dropdown. Add two attributes to the function, 0 and 1. Variable Random

For the next step, you will use a Gateway Module at the position in the process where you want the agent to differ and add two branches (click two times on the Gateway). Gateway

Condition both branches with the variable random that was created in the first step. The first branch has the condition "var random" equals "0".

Condition

The second branch must have the condition "var random" equals "1".

Condition

For the last step, just drag and drop the modules for each branch individually into the agent. Both A and B users will end up in the same branch again after passing through their individual branch. In the screenshot below, the users will all reach the Quiz module.

Quiz

For an overview of how many users enter each branch, go to your analytics and pick your agent. In the drill-down part of the analytics you are able to see the number of users for each branch.

Analytics

In this example, we can see in the analytics that out of 10 users that started the agent, 4 entered with the random variable set to "0" into the left branch, and 6 users entered with the random variable set to "1" into the right branch.