How to Trigger an Experience Based on Cookie Existence
You can launch an experience in Visually.io based on when a specific cookie exists regardless of its value.
If you are looking to launch an experience based on a specific cookie value, please refer to this article.
Follow the steps below to configure a Custom JS Trigger for your experience.
Step-by-Step Instructions
-
Open your experience in the Visually.io editor.
-
Click on the Trigger section.
-
Select Custom JS Trigger.
-
Paste the following code replacing
your-cookie-name
with the actual name of the cookie you’re checking for:
return new Promise(resolve => {
const COOKIE_NAME = `your-cookie-name`;
const exists = document.cookie
.split('; ')
.some(c => c.startsWith(`${encodeURIComponent(COOKIE_NAME)}`));
if (exists) {
resolve();
}
});