Setting up AB testing with Cloudflare Workers, through Sloth

Setting up AB testing with Cloudflare Workers, through Sloth

One of the most exciting abilities with Cloudflare Workers is the ability to run AB tests - and we’ve enabled this through Sloth. We’re actually running a live example of this on https://dantaylor.online/sloth-ab at the moment - and this example is used throughout this “how to” guide.

How to set-up an AB testing campaign

When logged into your Sloth dashboard, you need to select AB testing from the sidebar menu on the left hand-side. And then you need to click on “Add campaign”.

ab testing setup 1

When you’re first setting up a campaign, you’ll be met with a screen like this:

ab testing setup 2

And this is the interface for setting up an AB testing campaign. Once it’s completed it will look something like this:

ab testing setup 3

These fields are:

  1. The name of your AB testing campaign. This only appears in Sloth.
  2. This code is for user cookies.
  3. This is the URL that you want users to go to and then be redirected. This doesn’t need to be a real URL or resolve in a 200.
  4. Choose between Shadowed and Redirected. Shadowed tests proxy primary URL to variations, whilst Redirected tests 302 redirects to variations.
  5. Choose your traffic split, either custom or even. If you choose custom, the split total in the row manager must equal 100.
  6. Enter the URLs of your variation pages. These should be the pages you want to AB test, they can include parameters. If you’re testing one page against another, you should include it as a variant.
  7. You can enable or disable URLs as part of a test, or scrap them.

Reporting on edge AB tests

Whilst a lot of AB testing platforms have reporting dashboards, you’re running this test through a serverless application on a CDN.

In order to manage reporting, you need to use your analytics package, for example Google Analytics:

ab testing setup analytics

You can also set-up a Google Data Studio report fairly easily with your landing page paths and in-built analytics goal conversions to monitor AB testing through Sloth at scale - and with ease.