Building decision models with Sitecore Personalize: usage of programmable nodes
In our recent research of Sitecore CDP and Personalize, Kate Orlova and I looked into decision models, aiming to understand how to dynamically recommend the most relevant content variants based on specific rules. We soon discovered that decision models offer much more than a simple drag-and-drop canvas! In this article I will focus on programmable nodes, an important element of the toolset available to us in Sitecore Personalize.
Understanding decision models
Decision models are the foundational element of personalised content delivery in Sitecore Personalize. They incorporate several essential components:
The importance of programmable nodes
Programmable nodes are where developers and marketers collaborate to fine-tune the decision models. These nodes allow you to incorporate server-side JavaScript to process and analyse user behaviour data captured from Sitecore CDP across multiple sessions.
Why are programmable nodes so important?
Creating custom programmable nodes in Sitecore Personalize
To illustrate the process, let's look at an example of a custom programmable node. Imagine you want to calculate the total number of "VIEW" events across all sessions for a given user and output it as an integer.
领英推荐
(function ()
? ? function getNumberOfEvents(sessions, eventType) {
? ? ? ? var numberOfEvents = 0;
? ? ? ? for (var i = 0; i < sessions.length; i++) {
? ? ? ? ? ? var session = sessions[i];
? ? ? ? ? ? for (var j = 0; j < session.events.length; j++) {
? ? ? ? ? ? ? ? var event = session.events[j];
? ? ? ? ? ? ? ? if (event.type === eventType) {
? ? ? ? ? ? ? ? ? ? numberOfEvents++;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? return numberOfEvents;
? ? }
? ? var numberOfEvents = getNumberOfEvents(guest.sessions, 'VIEW');
? ? return numberOfEvents;
})();
In this code snippet, we define a function called getNumberOfEvents that calculates the number of "VIEW" events within each session and returns the total count.
Custom programmable nodes for unique use cases
Besides event calculations, you can build programmable nodes to cater to various other use cases. For instance, you could check the session state to determine if a user's session is still active:
(function ()
? ? var sessionRef;
? ? if (entity) {
? ? ? ? sessionRef = entity.ref;
? ? }
? ? var sessionStatus = "";
? ? for (var i = 0; i < guest.sessions.length; i++) {
? ? ? ? var session = guest.sessions[i];
? ? ? ? if (session.ref === sessionRef) {
? ? ? ? ? ? sessionStatus = session.Status;
? ? ? ? ? ? break;
? ? ? ? }
? ? }
? ? return sessionStatus;
})();
Alternatively, you might want to trigger specific actions based on the last event type, such as completion of checkout:
(function ()
? ? function getLastEvent(sessions) {
? ? ? ? var lastSession = sessions[sessions.length - 1];
? ? ? ? var lastEvent = lastSession.events[lastSession.events.length - 1];
? ? ? ? return lastEvent;
? ? }
? ? var lastEvent = getLastEvent(guest.sessions);
? ? return lastEvent.type;
})();
Empowering personalised experiences
Programmable nodes in Sitecore Personalize provide a powerful tool to create highly personalised user experiences. By leveraging server-side JavaScript and collaborating with technical experts, marketers can configure decision models to cater for various scenarios and user preferences. So, unlock the potential of programmable nodes and deliver outstanding content tailored precisely to your users' needs! ??
For a detailed guide on creating decision models, check out my colleague's article here. Once you have that foundation, you're all set to start your journey of customisation with programmable nodes. In my next articles I will talk more about other technical features of Sitecore Personalize. Stay tuned! ??
Product development leader with 20+ years of experience of orchestrating successful product roadmaps with multidisciplinary teams of all scales.
1 年Great article Anna and Kate. Clearly sets out how this can be achieved and why it is the future.