In the documentation, it is given that user tags to be defined during Pushwoosh initialization, this doesn't work well if I am trying to assign values in tags dynamically from user input. How can I work around this?

asked 12 Dec '17, 09:30
shashwat07's gravatar image

shashwat07
112

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

permanent link
answered 12 Dec '17, 10:24
iskoritzky's gravatar image

iskoritzky
3778

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.

(13 Dec '17, 06:06) shashwat07 shashwat07's gravatar image

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.

(13 Dec '17, 06:08) shashwat07 shashwat07's gravatar image

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

(15 Dec '17, 12:04) iskoritzky iskoritzky's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×438
×321
×111
×64
×46

question asked: 12 Dec '17, 09:30

question was seen: 284 times

last updated: 15 Dec '17, 12:04