Activity Tracking
Not Required for Most Partners
This feature is only needed for partners who either:
use SRI (Subresource Integrity) and cannot allow the Pushly loader to fetch updated SDK assets automatically, or
self-host the Pushly SDK (serve it from their own servers/CDN)
Overview
The Pushly SDK supports sending “content context” signals from your site to Pushly. These signals let Pushly build cohorts based on what a subscriber has viewed, how often they viewed it, and how recently.
This powers segmentation like:
Subscribers who visited any page tagged “Astrology” at least 4 times in the last 30 days
Subscribers who visited content tagged “Elections” in the last 7 days
Subscribers who visited multiple categories (ex: “sports” AND “politics”) over the last 14 days
These tags are defined by you at runtime and should map cleanly to your content taxonomy (categories, sections, keywords, authors, topics, etc.).
Prerequisites
The standard Pushly integration snippet must already be installed and running on the page.
window.PushlySDKmust be available before you call these methods.
If you call before the SDK is ready, queueing still works (see usage below), but you must ensure the integration snippet has executed first.
When to call
Call this after you’ve determined the page’s tags (usually once per page view):
Traditional multi-page sites: call once on page load after tags are known.
SPAs / client-side routing: call on every route change when the viewed content changes.
Avoid calling repeatedly for the same view (ex: on scroll, on timers, or in re-render loops).
Method: page_tag_visit
page_tag_visitRecords that the current subscriber viewed a page associated with one or more tags.
Signature
Parameters
tags(Array of strings) – required A list of 1+ tags to associate with this page view.
Tag rules / recommendations
Use stable, human-readable slugs (recommended):
["astrology", "sports", "politics"]Keep tags reasonably short (avoid dumping entire keyword lists)
Maximum of 20 tags per page view. Any tags beyond the first 20 will be ignored.
Do not include PII (no emails, names of private individuals, user IDs, etc.)
Examples
Basic example
Example with runtime tags from the page
SPA example (route changes)
(Use your router’s hook/event if you have one; popstate is just the generic baseline.)
Notes and common pitfalls
Order doesn’t matter:
['sports','politics']is the same as['politics','sports']Dedupe your tags before sending if your CMS can emit duplicates.
Don’t call it before the Pushly snippet runs. If you inline this in the
<head>, it can fire too early. Place it after the Pushly snippet or after your tag data is available.
Troubleshooting
If cohorts don’t populate as expected:
Confirm the Pushly base snippet is present and loading successfully (no blocked requests, no JS errors).
Confirm
window.PushlySDKexists and that calls are being queued/executed.Confirm the tags being passed are strings (not objects) and look like what you expect.
Confirm you’re sending tags on every relevant page view (especially for SPAs).
Last updated