Evaluators
Last updated
Was this helpful?
Last updated
Was this helpful?
Created: 05.12.22
Updated: 15.12.22
Author: Polina A.
Evaluator - is a custom JavaScript code. This code works on the page and returns a certain value based on the data on the page.
You can create evaluators for:
Custom targeting conditions: for example, if there is data about the user's age on the page, the evaluator can return the value for further use in targeting conditions for personalization campaigns.
Assigning values to variables in templates: for example, if there is a user's name on the page, the evaluator can return the value for use in the template. This way, you can embed the user's name into variations and create a more personalized user experience.
Assigning values in in recommendation strategies: for example, the evaluator can return the difference between the current cart total and the minimum cart total required for free shipping. Then a product with a price exceeding this difference can be suggested to the user.
Substituting promo codes for each day of the month: As part of the system's functionality, you can additionally segment user audiences and influence their interaction with the website. For example, you can offer a personalized promo code to a segment of users (corresponding to a specific date of purchase), and then, depending on whether it was used or not, show the next appropriate experience. With this evaluator, you can also see if the user used the promo code on that day or on any other, thus tracking the attribution window.
The evaluator runs only after the experience has been loaded on the page. This happens during page loading if there is no specific trigger in the experience targeting. Evaluators have a 4-second timeout and return "false" if no result is obtained within that time frame.
Evaluator code is a JavaScript code that returns a certain value. It can be simple code that retrieves text from a page element or code that fetches data from the browser, modifies it, and returns it as a result. Data sources for the evaluator's work can include:
HTML code of the website page (e.g., for the number of items in the cart).
Objects on the page – dataLayer, window (e.g., for obtaining the user's region).
User's browser – cookies, sessionStorage, localStorage (e.g., for passing data from CRM).
The evaluator's own code (e.g., for substituting various promo codes for different days of the month).
External front-end APIs which can supply the personalization platform with required data.
To avoid cases of returning an incorrect value or a zero value due to the absence of something on the page, we recommend using a JS promise
. This ensures that targeting conditions are calculated only after the evaluator returns a valid value.