{"_id":"55e5a4cad101191900f30b9d","__v":8,"category":{"_id":"55e58d16f493c11700584314","project":"55e58b63d101191900f30b13","__v":9,"pages":["55e58d21f11ba80d003238be","55e59fddd101191900f30b82","55e5a218f11ba80d00323911","55e5a28bf11ba80d00323915","55e5a2adf11ba80d00323917","55e5a335a603d62300f8926f","55e5a4cad101191900f30b9d","55e5a5396015ce1900eadb54","55e81c700f5df10d004a9c10"],"version":"55e58b63d101191900f30b16","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-09-01T11:33:42.203Z","from_sync":false,"order":1,"slug":"js-api","title":"JavaScript API"},"project":"55e58b63d101191900f30b13","parentDoc":null,"user":"5554788cb450630d00041dbc","version":{"_id":"55e58b63d101191900f30b16","__v":3,"project":"55e58b63d101191900f30b13","createdAt":"2015-09-01T11:26:27.668Z","releaseDate":"2015-09-01T11:26:27.668Z","categories":["55e58b65d101191900f30b17","55e58d16f493c11700584314","55e58d1bd101191900f30b1d"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-09-01T13:14:50.959Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":7,"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 PushCrew 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]","excerpt":"","slug":"remove-subscriber-from-a-particular-segment","type":"fn","title":"Remove Subscriber from a Particular Segment"}

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 PushCrew 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]