Snippets Collections
const waitForSiblingElementToBeRemoved = (form) => {
    // This Element are where any errors would appear
    const input = form.querySelector(`input[type='submit']`);

    // This observer looks for the sibling of the input submit button that appears 
    // and then removes when the request is complete
    new MutationObserver((entries, observer) => {
      log('entries[0].removeNodes: ', entries[0].removedNodes);
      if (!entries[0].removedNodes[0]?.classList.contains('ajax-progress')) return; 
      observer.disconnect(); // should this be moved after sendEvent 
      window.setTimeout(() => {
        if (input.classList.contains('error')) return; 
        log('Email has been submitted');
        sendEvent('pjs_email_submitted');
      }, 0);
    }).observe(input.parentElement, { childList: true, subtree: true }); // should be actually have two separate observers for each input?
  };
window.optimizely.get('visitor')

// example of getting specific pjs segment (from tb440)
window.optimizely.get('visitor').custom['22521880007']
star

Thu Mar 09 2023 21:10:32 GMT+0000 (Coordinated Universal Time)

#visitor #data #info #optimizely
star

Fri Feb 10 2023 20:50:00 GMT+0000 (Coordinated Universal Time)

#optimizely #visitor #id

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension