{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","params":[],"results":{"codes":[]},"settings":""},"next":{"description":"","pages":[]},"title":"Remove Subscriber from a Particular Segment","type":"fn","slug":"remove-subscriber-from-a-particular-segment","excerpt":"","body":"This is used to remove the current subscriber from a particular segment. The same is pushed into the global _pcq queue.\n\n**Notes:**\n\n1) This operation will only work reliably if it's placed inside the [APIReady callback](http://api.pushcrew.com/docs/is-api-ready). (Example given below)\n\n**Parameters:**\n\n1) removeSubscriberFromSegment: Command to remove the subscriber from the specified segment\n2) segmentName: This is a string used to identify the segment.\n3) callbackFunctionName: (Optional)\nName of the function to be executed when the subscriber gets removed from the segment successfully. This is optional.\n\nExample usage:\n\n_pcq.push(['removeSubscriberFromSegment', 'homepage', callbackFunction]); \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"window._pcq = window._pcq || [];\\n\\n_pcq.push(['APIReady', callbackOnAPIReady]); //will execute callback function when VWO Engage API is ready\\n\\nfunction callbackOnAPIReady() {\\n    _pcq.push(['removeSubscriberFromSegment', 'homepage', callbackForRemoveFromSegment]);  \\n}\\n\\nfunction callbackForRemoveFromSegment(response) {\\n    if(response === -1) {\\n        console.log('User is not a subscriber or has blocked notifications');\\n    }\\n  \\n    if(response === false) {\\n        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.');\\n    }\\n  \\n    if(response === true) {\\n        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');\\n    }\\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","updates":[],"order":8,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"55e5a4cad101191900f30b9d","__v":9,"createdAt":"2015-09-01T13:14:50.959Z","category":{"sync":{"isSync":false,"url":""},"pages":["55e58d21f11ba80d003238be","55e59fddd101191900f30b82","55e5a218f11ba80d00323911","55e5a28bf11ba80d00323915","55e5a2adf11ba80d00323917","55e5a335a603d62300f8926f","55e5a4cad101191900f30b9d","55e5a5396015ce1900eadb54","55e81c700f5df10d004a9c10"],"title":"JavaScript API","slug":"js-api","order":1,"from_sync":false,"reference":false,"_id":"55e58d16f493c11700584314","project":"55e58b63d101191900f30b13","__v":9,"createdAt":"2015-09-01T11:33:42.203Z","version":"55e58b63d101191900f30b16"},"githubsync":"","project":"55e58b63d101191900f30b13","parentDoc":null,"user":"5554788cb450630d00041dbc","version":{"version":"1.0","version_clean":"1.0.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["55e58b65d101191900f30b17","55e58d16f493c11700584314","55e58d1bd101191900f30b1d"],"_id":"55e58b63d101191900f30b16","__v":3,"createdAt":"2015-09-01T11:26:27.668Z","releaseDate":"2015-09-01T11:26:27.668Z","project":"55e58b63d101191900f30b13"}}

Remove Subscriber from a Particular Segment


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](http://api.pushcrew.com/docs/is-api-ready). (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]); [block:code] { "codes": [ { "code": "window._pcq = window._pcq || [];\n\n_pcq.push(['APIReady', callbackOnAPIReady]); //will execute callback function when VWO Engage API is ready\n\nfunction callbackOnAPIReady() {\n _pcq.push(['removeSubscriberFromSegment', 'homepage', callbackForRemoveFromSegment]); \n}\n\nfunction callbackForRemoveFromSegment(response) {\n if(response === -1) {\n console.log('User is not a subscriber or has blocked notifications');\n }\n \n if(response === false) {\n 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.');\n }\n \n if(response === true) {\n 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');\n }\n}", "language": "javascript" } ] } [/block]