how to dynamically subscribe users to tags?

Comments

4 comments

  • Avatar
    Ivan Skoritzky

    Hello,

    May I ask you to describe the issue and use case in more details? Could you please specify how exactly you have assigned the value? Am I correct that you are using /setTags method?

    Regards, Ivan

  • Avatar
    shashwat07

    No, I am adding tag during initialization on js

    function PushSubs(){ var interest = document.getElementById('myInterests').value;

    Pushwoosh.push(['init', { logLevel: 'info', applicationCode: 'XXXXX-XXXXX', autoSubscribe: false, tags: {'Sports Interest': interest }}]);

    Pushwoosh.subscribe(); }

    Pushwoosh.push(['onSubscribe', function(api) { console.log('User successfully subscribed'); }]);

    This code works fine for setting tag dynamically, but it creates other problems since Pushwoosh is initialized only when this function PushSubs() is called.

  • Avatar
    shashwat07

    If I put the init outside any particular function, everything works fine except the part where I can add users to tags dynamically. Since,the initialization happens as soon as the page loads.

  • Avatar
    Ivan Skoritzky

    Hello,

    Actually, you can set onReady instead of onSubscribe or use just Pushwoosh.push(function(api).

    You will find more detailed information in our Guide:

    https://docs.pushwoosh.com/v1.0/docs/web-push-sdk-30#section-event-listeners

    Could you please check it and let us know about the results?

    Regards, Ivan

Please sign in to leave a comment.