Subscribe to topics
Let users subscribe to topics and push notifications at once, then target them based on the topics they chose to follow.
Letting users subscribe to topics is a powerful way to both acquire new push subscribers and target them efficiently. WonderPush provides a very simple way to create user interfaces similar to this:
![Screenshot 2019-11-26 at 15.39.48.png 430](https://files.readme.io/236ca83-Screenshot_2019-11-26_at_15.39.48.png)
When users activate a switch, here's what happens:
- if they are not subscribed to push notifications, they will by prompted to subscribe,
- if they are subscribed, their data on WonderPush will simply be updated.
Here's what the subscription looks like:
![Screenshot 2019-11-26 at 15.39.57.png 880](https://files.readme.io/fc4679a-Screenshot_2019-11-26_at_15.39.57.png)
Step 1. Adding the required HTML
To add a topic switch, all you need is to add a little bit of HTML within the page.
Adding multiple switches for Sports, Arts, Business and Technology would require the following HTML:
<div class="wonderpush-tag-switch" data-tag="sports" data-sentence="Sports: "></div>
<div class="wonderpush-tag-switch" data-tag="arts" data-sentence="Arts: "></div>
<div class="wonderpush-tag-switch" data-tag="business" data-sentence="Business: "></div>
<div class="wonderpush-tag-switch" data-tag="technology" data-sentence="Technology: "></div>
And would render something like this:
![Screenshot 2019-11-26 at 15.39.48.png 430](https://files.readme.io/fac1399-Screenshot_2019-11-26_at_15.39.48.png)
The complete reference of customization options for the tag switch is available in the Website SDK reference.
Step 2. Testing your changes
It's time to test your changes:
- go to your web page and click on a switch,
- make sure you are prompted to subscribe to push notifications if you haven't already
- activate one or more switches.
Go to your dashboard and find your installation in Segments / All users, make the right tags have been added to your installation:
![Screenshot 2019-11-26 at 17.41.29.png 600](https://files.readme.io/9cfb416-Screenshot_2019-11-26_at_17.41.29.png)
Step 3. Creating segments to target users
We're now going to create a segment to target users that have checked the sports
switch. In your dashboard go to Segments and click Create segment.
Create a new segment with the following data:
![Screenshot 2019-11-26 at 17.43.20.png 1312](https://files.readme.io/f1dab45-Screenshot_2019-11-26_at_17.43.20.png)
That's it! Now all you have to do to reach users who like sports is create a new notification with the following audience:
![Screenshot 2019-11-26 at 17.44.58.png 1138](https://files.readme.io/19ffd69-Screenshot_2019-11-26_at_17.44.58.png)
Updated 8 months ago