Condition types for edge extensions
In a tag rule, a condition is evaluated after an event has occurred. All conditions must return true in order for the rule to continue processing. Condition types are provided by extensions and evaluate whether something is true or false, returning a boolean value.
As an example, an extension could provide a “viewport contains” condition type wherein the user could specify a CSS selector. When the condition is evaluated on the client’s website, the extension would be able to find elements matching the CSS selector and return whether any of them are contained within the user’s viewport.
This document covers how to define condition types for an edge extension in Adobe Experience Platform.
Condition types typically consist of the following:
- A view shown within the Experience Platform UI and Data Collection UI that allows users to modify settings for the condition.
- A library module emitted within the tag runtime library to interpret the settings and evaluate a condition.
For example, if you want to evaluate whether the user is on the host example.com
, your module may look like this.
module.exports = (context) => {
const URL = context.arc.event.xdm.web.webpageDetails.URL;
return URL.endsWith("adobelaunch.com");
};
If you want to make the hostname configurable by the user to allow the input of a hostname and save it to the settings object, the object might look similar to this example.
{
"hostname": "example.com"
}
In order to operate on the user-defined hostname, your module would need to change to this:
module.exports = (context) => {
const URL = context.arc.event.xdm.web.webpageDetails.URL;
return URL.endsWith(settings.hostname);
};
Condition result
The result returned by a condition module can be one of the following:
- A boolean value (
true
orfalse
). - A promise that returns a boolean value once resolved.
Library module context
All condition modules have access to a context
variable that is provided when the module is called. You can learn more here.