This is used to remove the current subscriber from a particular segment. The same is pushed into the global _pcq queue.

Notes:

  1. This operation will only work reliably if it's placed inside the APIReady callback. (Example given below)

Parameters:

  1. removeSubscriberFromSegment: Command to remove the subscriber from the specified segment
  2. segmentName: This is a string used to identify the segment.
  3. callbackFunctionName: (Optional)
    Name of the function to be executed when the subscriber gets removed from the segment successfully. This is optional.

Example usage:

_pcq.push(['removeSubscriberFromSegment', 'homepage', callbackFunction]);

window._pcq = window._pcq || [];

_pcq.push(['APIReady', callbackOnAPIReady]); //will execute callback function when VWO Engage API is ready

function callbackOnAPIReady() {
    _pcq.push(['removeSubscriberFromSegment', 'homepage', callbackForRemoveFromSegment]);  
}

function callbackForRemoveFromSegment(response) {
    if(response === -1) {
        console.log('User is not a subscriber or has blocked notifications');
    }
  
    if(response === false) {
        console.log('Segment name provided is not valid. Maximum length of segment name can be 30 chars and it can only contain alphanumeric characters, underscore and dash.');
    }
  
    if(response === true) {
        console.log('User got removed from the segment successfully. Now you may run any code you wish to execute after user gets removed from segment successfully');
    }
}