User Journey Conditions
Conditions are an important part of a User Journey: they control when and if the
journey's action should be executed. Within the User Journey JSON, the condition
should be placed within the (optional) condition key. A journey without a
condition triggers once (on page load), and then never again within the same
page view. Conditions can also be used for journey preconditions, as described
in the journey groups page.
Built-in Blink conditions are self-managed: they set up in such a way as to check whether they might have been met every time something of relevance changes. This means the journey will trigger exactly when the condition is met (for example, in a condition requiring the page to be 50% scrolled, the condition will be met as soon as the user scrolls to 50% of the page). This can also mean that conditions may spuriously be re-evaluated and considered met, triggering the action once more, maybe at an unexpected time. See the documentation on throttles page for controlling how many times the actions for a journey get executed within the same context.
Below, you can see an overview of built-in Blink conditions. To see how to create your own conditions, jump to the custom conditions section.
Page scroll condition
Documentation missing
Example:
{
"type": "pageScroll",
"percent": 75
}
Stay on page condition
Documentation missing
Example:
{
"type": "stayOnPage",
"seconds": 30
}
Inactive condition
Documentation missing
Example:
{
"type": "inactive",
"seconds": 30
}
User agent condition
Documentation missing
Example:
{
"type": "userAgent",
"device": "mobile"
}
Ad blocker condition
Documentation missing
Example:
{
"type": "adBlockEnabled"
}
Nth page visit condition
Documentation missing
Example:
{
"type": "nthPage",
"numPages": 4,
"pathExclude": [
"/tag/.*",
"/author/.*",
"/category/.*",
"/"
]
}
Variable condition
Documentation missing
Example:
{
"type": "variable",
"key": "some_counter_increased_by_a_different_journey",
"equal": 14
}
Negative condition
Documentation missing
Example:
{
"type": "not",
"op": {
"type": "userAgent",
"device": "mobile"
}
}
or the shorthand version:
{
"type": "userAgent",
"exclude": true,
"device": "mobile"
}
Composite conditions: and/or
Documentation missing
Example:
{
"type": "and",
"ops": [
"adBlockEnabled",
{
"type": "isDonor",
"exclude": true
}
]
}
Custom conditions
In addition to the built-in conditions, the Blink SDK also supports custom conditions through the use of the function condition, which simply calls an arbitrary JavaScript function from your website. This allows a lot of flexibility for you to define your own journeys, while still taking advantage of the Blink infrastructure and ecosystem.
Conditions are generally synchronous, but the SDK also provides support for async conditions (that may incur, for example, a call to a remote server).
Conditions are generally stateless and have no side effects, but there are exceptions (see Nth page visit condition). Custom conditions with side effects should be implemented with care: the Blink SDK makes no strong guarantees about how many times a condition gets re-evaluated. Thus, conditions with side effects or expensive, non-cached server calls are generally discouraged.
Function condition
Documentation missing
Example:
{
"type": "function",
"function": "blinkFunctions.checkIsArticlePage"
}