Activity Tracking

triangle-exclamation

Not Required for Most Partners

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

  1. The standard Pushly integration snippet must already be installed and running on the page.

  2. window.PushlySDK must 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

Records 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:

  1. Confirm the Pushly base snippet is present and loading successfully (no blocked requests, no JS errors).

  2. Confirm window.PushlySDK exists and that calls are being queued/executed.

  3. Confirm the tags being passed are strings (not objects) and look like what you expect.

  4. Confirm you’re sending tags on every relevant page view (especially for SPAs).

Last updated