Automatically tag and target Web Push subscribers by page
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:- Use the
subscriptionChange
event to detect Web Push opt-ins - Apply custom data tags when a user subscribes
- Segment users by tag for targeted campaigns
- Automate messaging sequences based on tag and timing
Setup
1. Tag users with page-specific metadata
Once 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.- The
subscriptionChange
event fires when a user’s subscription status changes. - If
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
.
2. Segment users by tag
Once tags are applied, you can use Segments or API Filters to target users based on those tags. For example:- Send a campaign to users where
subscription_page
is “gaming” - Create dynamic segments based on tag values and timing (e.g., hours since first session)
3. Automate follow-up messaging
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 subscribersSegment 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.4. Combine segments with message templates
Once segments are created:- Build Templates for each stage in the campaign (e.g., intro, reminder, promo).
- Use Journeys to send these messages when users enter the appropriate segment.
- Invite to a gaming community or social group
- Recommend trending articles related to their topic
- Send an exclusive offer or discount code
Best practices and gotchas
- Use meaningful tag names and values that reflect actual user intent
- Extract tag values dynamically if possible, e.g.:
- Monitor tagging success via
console.log()
or browser dev tools
- Re-tagging users unnecessarily on every page load (only tag when subscription is new)
- Including PII in tags (e.g., name, email)
- Hardcoding tag values across your entire site
Congrats on enriching your user data with contextual information!
Additional resources: