Skip to content
  • There are no suggestions because the search field is empty.

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

  1. Open your experience in the Visually.io editor.

  2. Click on the Trigger section.

  3. Select Custom JS Trigger.

  4. 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();
  }
});