Remove subscriber from a particular segment

Posted in General by Tom Arthey Tue Jul 10 2018 11:15:28 GMT+0000 (Coordinated Universal Time)·6·Viewed 816 times

Can I use this to remove a subscriber from the global segment? It doesn't appear to be working.. If not, you should really update your documentation because I've spent a couple of days building under the impression that I could add a one click opt-out to our site.
July 10, 2018

Hi Tom,

This is Piyush from PushCrew Support team. Can you please let us know what is the API response you are getting as we can remove the user from the segment using the above mentioned API?

Regards,
Piyush

July 10, 2018

Hi Piyush,

Thanks for the swift reply! This is my unsub code at the moment:

window._pcq = window._pcq || [];
_pcq.push(['APIReady', onAPIReady]);

function onAPIReady() {
    var subscriberId = pushcrew.subscriberId;

    if(subscriberId !== false && subscriberId !== -1) {
        // ... show unsub button
    }

    $("#unsub-button").click(function(){
        // ...
        _pcq.push(["removeSubscriberFromSegment", "global", onRemoveFromGlobal]);
    });
}

function onRemoveFromGlobal(response) {
    if (response === 1) {
       // I can't seem to get here
    } else if (response === -1) {
       // This is where I end up if the user has blocked notifications
    } else {
       // This is where I end up if the user is allowing notifications
    }

    // ...
};

The code used to show the notification pop-up to the user is here:

(function(p,u,s,h){
    p._pcq=p._pcq||[];
    p._pcq.push(['_currentTime',Date.now()]);
    s=u.createElement('script');
    s.type='text/javascript';
    s.async=true;
    s.src='https://cdn.pushcrew.com/js/blahblahblah.js';
    h=u.getElementsByTagName('script')[0];
    h.parentNode.insertBefore(s,h);
})(window,document);
July 10, 2018

Just noticed I'm getting CORB issues in Chrome atleast:

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://pushcrew.com/c.gif?hash=blahblahblah&subscriberId=blahblahblah&subscriptionId=blahblahblah&segment=global&action=remove-segment with MIME type text/html. See https://www.chromestatus.com/feature/blahblahblah for more details

July 10, 2018

Struggling to understand why this is a .gif URL and why it's trying to return text/html.. could this be a bug in your code?

July 10, 2018

Also having problems in Firefox, but less obvious errors.. hoping it's the same issue!

  
Markdown is allowed