Web optimisation with
genetic algorithms

encode

Introduction

In this research project we will be investigating the use of genetic algorithms to optimise interactions on a website, specifically where best to place a call-to-action (CTA) button on an image.

Why CTA? The $300m button

An old story, widely shared in the UX community, is that of the $300m button.

In the early 2000s, a large e-commerce site (probably Amazon, but no-one is telling!) conducted a usability study on the placement of their checkout button. The test was really simple: how many people clicked on the button in its new position, compared to how many people clicked on the button in its old position.

The results were startling: the increase in traffic through the new button placement the study demonstrated that $300 million in revenue had been missed, simply because the old button was in the 'wrong' place!

Presentation

First of all check out the presentation to get an idea of what we are researching. In this presentation we give a short introduction to genetic algorithms and how we'd use them in a web setting.

As you'll see from the presentation, the problem space has the following components:

Terminology

Given the above summary, we will use the following terms:

TermDefinitionExample
OrganismThe class of objects we are evolvingAn image with a button superimposed on it
AttributeThe qualities of an organism we changing from generation to generationThe fill colour of the button
GeneThe encoding of an attribute as a binary representationFill colour can be encoded as 24 digit string of 0s and 1s
BitA 0 or 1 in a gene11111000110
GenomeThe complete set of an organism's attributes encoded as genesA 1024 digit string of 0s and 1s
ExpressionThe translation of a gene into the value of an attributeThe gene encoded as 1111 1111 0000 0000 0000 0000 is expressed as the fill colour red
EnvironmentThe landscape the organism lives inA web page designed for people to identify a CTA and click through
ConstraintAttributes that are dependent on other attributes or aspects of the environmentText colour needs to contrast against the colour of its background
ViabilityThe ability of an organism to survive in an environment A web page is constrained by typography choice and illustration style; a CTA organism that doesn't abide by these constraints isn't considered

The algorithm

algo

Now we have defined the problem and terminology, our solution - the genetic algorithm - proceeds as follows:

Generation 1

gen1

In the first generation we create 1000 organisms, with randomly chosen attributes encoded in binary representations.

Generation n: step 1, select using fitness function

gen1

Our fitness function is click-through rate (CTR), so we simply count the number of click-throughs on each button.

After a set number of total click-throughs, we select the top 500 organisms (measured by CTR), and discard the rest. These 500 organisms can be thought of as the selected parents of generation n.

Generation n: step 2, breeding the fittest parents to create offspring

Breeding is through a combination of crossover of pairs of selected parents to create new offspring that inherit characteristics of both parents. These offspring are then given slight mutations to promote innovation.

Crossover

gen1
Crossover

For crossover we take a random pair of parents and "crossover" their genomes:

Mutation

gen1
Mutation

In addition to crossover, we want to introduce a random element of mutation; this is so that there is a chance that innovation can occur - otherwise we may be in danger of shuffling attributes rather than evolving them.

At the end of the selection, crossover and mutation processes, we will have 1000 organisms in generation n: the fittest 500 parents from generation n-1, and 500 offspring with slightly mutated genomes derived from these parents.

Loop to generation n+1 or End?

We then loop this process for as many generations as we wish. Choosing when to end the looping is an optimisation problem in itself, and there are a couple of methods available:

@copyright saintnicks 2026