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.
subscriptionChange
event to detect Web Push opt-inssubscriptionChange
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.https://example.com/gaming/article123
, the subscription_page
tag will be gaming
.
subscription_page
is “gaming”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 |
<
) to prevent users from lingering in segments once the messaging window has passed.console.log()
or browser dev tools