Learn how to automatically tag Web Push subscribers based on the page they opted in from and use those tags to create segments or trigger automated messaging campaigns in OneSignal.
You can deliver more personalized and timely push notifications by tagging users based on the specific page or content they subscribed from. In this guide, you’ll learn how to:
subscriptionChange
event to detect Web Push opt-insOnce a user subscribes to push notifications, you can tag them with contextual data—such as the page type or topic they were viewing. This enables targeted follow-ups based on what the user showed interest in.
How this works:
subscriptionChange
event fires when a user’s subscription status changes.isSubscribed === true
, the user has just opted in.window.location.pathname.split('/')[1]
captures the first segment of the page path as the subscription context.page_topic
can be dynamically set based on your page’s metadata or content.Example: If the URL is https://example.com/gaming/article123
, the subscription_page
tag will be gaming
.
Once tags are applied, you can use Segments or API Filters to target users based on those tags.
For example:
subscription_page
is “gaming”You can build drip-style campaigns that trigger messages based on when the user subscribed and what content they subscribed under.
Example: Drip campaign for gaming subscribers
Segment Name | Filters | Description |
---|---|---|
Gaming 1 | subscription_page = gaming AND First Session > 2h AND < 24h | Reach out 2–24 hours after subscription |
Gaming 2 | subscription_page = gaming AND First Session > 24h AND < 48h | Follow up 1 day later |
Gaming 3 | subscription_page = gaming AND First Session > 72h AND < 96h | Final check-in after 3 days |
Use upper time limits (<
) to prevent users from lingering in segments once the messaging window has passed.
Once segments are created:
Example message ideas:
console.log()
or browser dev toolsAvoid:
Congrats on enriching your user data with contextual information! Additional resources:
Learn how to automatically tag Web Push subscribers based on the page they opted in from and use those tags to create segments or trigger automated messaging campaigns in OneSignal.
You can deliver more personalized and timely push notifications by tagging users based on the specific page or content they subscribed from. In this guide, you’ll learn how to:
subscriptionChange
event to detect Web Push opt-insOnce a user subscribes to push notifications, you can tag them with contextual data—such as the page type or topic they were viewing. This enables targeted follow-ups based on what the user showed interest in.
How this works:
subscriptionChange
event fires when a user’s subscription status changes.isSubscribed === true
, the user has just opted in.window.location.pathname.split('/')[1]
captures the first segment of the page path as the subscription context.page_topic
can be dynamically set based on your page’s metadata or content.Example: If the URL is https://example.com/gaming/article123
, the subscription_page
tag will be gaming
.
Once tags are applied, you can use Segments or API Filters to target users based on those tags.
For example:
subscription_page
is “gaming”You can build drip-style campaigns that trigger messages based on when the user subscribed and what content they subscribed under.
Example: Drip campaign for gaming subscribers
Segment Name | Filters | Description |
---|---|---|
Gaming 1 | subscription_page = gaming AND First Session > 2h AND < 24h | Reach out 2–24 hours after subscription |
Gaming 2 | subscription_page = gaming AND First Session > 24h AND < 48h | Follow up 1 day later |
Gaming 3 | subscription_page = gaming AND First Session > 72h AND < 96h | Final check-in after 3 days |
Use upper time limits (<
) to prevent users from lingering in segments once the messaging window has passed.
Once segments are created:
Example message ideas:
console.log()
or browser dev toolsAvoid:
Congrats on enriching your user data with contextual information! Additional resources: