Tags: Subscription Page
How to target Web Push users based on where they subscribed from
In this guide, we'll demonstrate how to use the the OneSignal Subscription Change Event and Send Tags methods to tag and segment Web Push users based on the page they subscribed from on your website.
Tag Users with Subscription Change Event & Custom Tags
Once a user has subscribed to notifications, OneSignal data tags can help track the page topic they subscribed under. You can expand this tagging to include other metadata that are present on the page that you want to track for this user.
OneSignal's tagging functionality has many applications, and you can learn more in our Adding Data Tags guide.
In the following example code snippet, when the subscriptionChange
event shows isSubscribed === true
, that means the user subscribed on the current page, after which you can then tag them with the sendTags
method.
let page_topic = 'sports';
OneSignal.push(function() {
OneSignal.on('subscriptionChange', function(isSubscribed) {
if (isSubscribed === true) {
console.log('The user subscription state is now:', isSubscribed);
var pathArray = window.location.pathname.split('/');
OneSignal.User.addTags({
"subscription_page": pathArray[1],
"subscription_page_topic": page_topic,
}).then(function(tagsSent) {
// Callback called when tags have finished sending
console.log(tagsSent);
});
}
});
});
In this example, "subscription_page" and "subscription_page_topic" are the tag keys, while window.location.pathname
and page_topic
are the tag values.
Use Segments or API Filters to Target Users by Tags
As soon as this tag data is added, you can target those subscribers based on the associated tags by using Segments or API Filters.
Automated Message Campaigns Based on Subscription Page
Using Automated Messages you can setup campaigns to automatically target users x amount of times after they have subscribed.
For example, if I subscribe to a "subscription_page" = "gaming". I want to be updated on all items related to this topic.
We can automate message campaigns by creating segments:
Segment Name | Data Filters | Details |
---|---|---|
Gaming 1 | Tag: subscription_page is gaming AND First Session greater than 2 hours AND First Session less than 24 hours | All users that subscribed in the gaming section of my site and 2 hours has passed. |
Gaming 2 | Tag: subscription_page is gaming AND First Session greater than 24 hours AND First Session less than 48 hours | 24 hours later, they will be added to this segment. |
Gaming 3 | Tag: subscription_page is gaming AND First Session greater than 72 hours AND First Session less than 96 hours | 72 hours later, they will be added to this segment. |
In this sequence, all users that subscribed to the "gaming" section of our site will be added to these segments after 2 hours, 24 hours and 72 hours. The upper limits are not required but will help remove subscribers after the time has passed.
Next we setup our Templates of what information we want to send to the users. Common examples would be:
- Link to social media to get them involved deeper in the community.
- Share popular blog posts or information.
- Send a small discount or promo code to keep them engaged.
Last step is to combine the Segments and Templates into the Automated Messages.
Updated 10 months ago