Website Personalization: How Sampling Algorithms Support the Message Delivery

| | 4 min read

Website Personalization

Website personalization is tailoring a website's content and user experience to match individual users' preferences, interests, and behaviour. With the rise of big data and advanced analytics, it has become increasingly easy to track user's behaviour and use that data to create personalized experiences. Personalization can improve user engagement, increase conversion rates, and enhance customer loyalty.

In my previous post, you can read more about this and the high-level structure of our website personalization engine.

Website personalization has many use cases, such as e-commerce, online news, and recommendation systems. In e-commerce, personalization can show the most relevant products to the user and increase the likelihood of purchasing. In news websites, it can be used to display articles that are most relevant to the user's interests. In recommendation systems, it can be used to suggest items most likely to be of interest to the user.

Select which message to show

However, defining a dynamic journey tailored to individual users' preferences and interests is a key challenge in website personalization. One aspect of this challenge with the message delivery system1 is to select the most appropriate item or items from the multiple options suggested by the personalization engine. The common use cases are

  1. The personalization engine allocates more than one message for the visitor, and those messages compete for a specific slot on the website.
  2. From the set of recommendations the personalisation engine provides, we need to display up to n messages in the given slot.

To address this issue, developers often turn to algorithms such as Roulette Wheel Selection2 and Stochastic Universal Sampling3 (SUS) to help pick the most relevant items based on their weight.

 

 

Roulette Wheel Selection

Roulette Wheel Selection is a method of randomly selecting an item from a list based on its weight. The items, in this case, messages, are assigned a weight based on their relevance or likelihood of interest to the user. The roulette wheel selection algorithm is used to randomly select a message based on its weight, giving each message a fair chance of being chosen while still considering its relevance to the user. This makes roulette wheel selection an effective method for delivering messages to the visitor in the context of website personalization.

Here's an example of a simple JavaScript function that implements roulette wheel selection:

function pickMessage(messages) {
    var totalWeight = messages.reduce((total, message) => total + message.weight, 0);
    var currentWeight = 0;
    var randomNumber = Math.random() * totalWeight;
    for (var message of messages) {
        currentWeight += message.weight;
        if (currentWeight > randomNumber) {
            return message;
        }
    }
}

Stochastic Universal Sampling

Stochastic Universal Sampling, on the other hand, is a method that allows you to pick up to n items randomly based on their weight. The algorithm generates n random points on the weight line and selects the first item that falls under it. The selection of n random points ensures that each point has an equal chance of falling under any item. This helps to distribute the chances of selection evenly across the weight line.

Here is an example of a JavaScript function for Stochastic Universal Sampling that implements this method:

function pickMessages(messages, n) {
    var selectedMessages = [];
    var totalWeight = messages.reduce((total, message) => total + message.weight, 0);
    var pointers = Array.from({length: n}, () => Math.random() * totalWeight);
    pointers.sort((a,b) => a-b);
    var currentWeight = 0;
    var index = 0;
    var selectedIndices = new Set();
    for (var i = 0; i < n; i++) {
        while(pointers[i] >= currentWeight) {
            currentWeight += messages[index++].weight;
        }
        if(!selectedIndices.has(index-1)){
            selectedIndices.add(index-1);
            selectedMessages.push(messages[index-1]);
        }
    }
    return selectedMessages;
}

Example

If you refresh this page, different messages appear in the sidebar and content area. We are using Roulette Wheel Selection here to pick one of the messages provided by the personalization engine.

Conclusion

It's worth noting that Roulette Wheel Selection and Stochastic Universal Sampling are relatively simple to implement, making them well-suited for the message delivery system of any website personalization system. Both algorithms are easy to understand and require minimal computation, so they can be integrated into the website's codebase without too much effort. However, they are just a small piece of the larger puzzle when it comes to website personalization. There are many other pieces to consider, such as the persona detection system, rules engine, message delivery system and the personalization engine that runs the show.

The personalization engine can even collect data on the messages that get more attention from the visitor and fine-tune the message delivery on the go.

Website personalization technology and a marketing strategy are the keys to delivering personalized experiences that will engage and retain your audience. Need more information on how we are doing this on Zyxware Website, please schedule a meeting with me.