How to configure the Azion A/B Testing integration

A/B Testing is a serverless integration based on an edge function, available at Azion Marketplace.

This function allows the distribution of different scenarios to be better controlled during the test run, and to identify the most successful variants.

Some other benefits of A/B Testing as an edge function include:

  1. Creating multiple variants in a single JSON file (A, B, C, and more).
  2. Varying how traffic flows.
  3. Combining test rules with business rules (WAF, bot protection, and more).
  4. Improving the users’ experience. Compared to integrations that use JavaScript to perform A/B tests, the time it takes to load a page isn’t affected and is significantly faster.

How does the A/B Testing integration work?

Section titled How does the A/B Testing integration work?

Test settings are defined in the edge function using JSON format parameters, called Arguments. These Arguments list attributes related to each version being tested, such as probability, cookie values, and others.

The function’s algorithm distributes the request according to a defined probability when it arrives at one of Azion’s edge nodes. Then, it sets the cookie with the expiry time and the values specified for each variable. From that point on, all traffic from the client that made the request is redirected to the selected version.

When a new request is made by another client, a cookie is set and all traffic is redirected to another version (or even the same) according to the probability you set up. From this point on, all traffic from this client is redirected to this version.

The edge node then forwards the query to the originating application, which returns the content of the test page, and the edge delivers the content to the user.

A/B Testing is available at the Azion Marketplace and can be accessed through Azion Console, going to Products menu > Marketplace.

You can understand how to install and configure an A/B test by reading the How to install the A/B tests integration from Azion Marketplace guide.

Example of an A/B Testing JSON file configuration

Section titled Example of an A/B Testing JSON file configuration

Below is an example of what a JSON file configuration looks like for a basic A/B Testing function. In this particular case, the first variant is passed with a 90% (0.9) probability, and the second variant is passed with a 10% (0.1) probability.

"param": {
"cookie": {
"name": "MYABTEST_NAME__",
"expiration": "Wed, 04 May 2021 10:16:00 GMT",
"max_age": 600,
"domain": "localhost",
"path": "/"
"a": {
"cookie_value": "A_VARIANT",
"prob": 0.9,
"addresses_list": "",
"originid": "uuid1",
"live_ingest": false,
"protocol_policy": "https",
"path": "",
"cache_key": "test_a",
"host": "localhost"
"b": {
"cookie_value": "B_VARIANT",
"prob": 0.1,
"addresses_list": "",
"originid": "uuid2",
"live_ingest": false,
"protocol_policy": "https",
"path": "",
"cache_key": "test_b",
"host": "localhost"

Defining the rules on Rules Engine

Section titled Defining the rules on Rules Engine

The set of conditions that must be met for behaviors to be executed are determined by the rules in the Rules Engine. You can use the Default Rule to run your function with no conditions, or create a new rule to configure trigger conditions of your function.

Choose the variables, comparison operators, and strings to create your business rule, as in the following example:

  • If: ${uri} is equal /home

Logic: logical operator, variable, comparison operator, string.

This rule is executed if the URL accessed is equal to the string

Add the behaviors you want to be carried out when the rule’s conditions are met, as in the following example:

Then: Run Function MyABTestFunction

Logic: logical operator, action, function.

In this example, if the conditions defined in the rules are satisfied, then the function MyABTestFunction will be executed.

Finally, save your edge application and the new function will be ready.

go to A/B Test guide