npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aptxx/tracktag

v0.0.4

Published

Lightweight client-side tracking SDK for Lander pages

Readme

tracktag

Lightweight client-side tracking SDK for Lander pages. Records clicks, fires third-party click trackers, and reports conversions to a tracking server (Voluum / Binom style).

  • Zero runtime dependencies. Small footprint, no hard size budget.
  • Server-authored URLs. The SDK never synthesizes or signs URLs — every clickUrl / clickTrackers / postbackUrl comes from the Click endpoint response.
  • Smart transport. clickTrackers: sendBeacon → Image → fetch; conversion/update: Image pixel (CORS-safe).

Install

Via CDN (jsDelivr):

<!-- @latest always points to the newest release -->
<script src="https://cdn.jsdelivr.net/npm/@aptxx/tracktag@latest/dist/tracktag.min.js"></script>

For production, pin a specific version so breaking changes don't auto-roll into your pages:

<script src="https://cdn.jsdelivr.net/npm/@aptxx/[email protected]/dist/tracktag.min.js"></script>

Or download dist/tracktag.min.js and host it yourself.

Usage

<!-- Async-load the SDK -->
<script async src="https://cdn.jsdelivr.net/npm/@aptxx/tracktag@latest/dist/tracktag.min.js"></script>

<!-- Publisher stub: buffers calls into .q before the SDK loads -->
<script>
  window.tracktag = window.tracktag || function () {
    (window.tracktag.q = window.tracktag.q || []).push(arguments);
  };
</script>
<script>
  tracktag('config', { endpoint: 'https://track.example.com/click' });
</script>

<button onclick="tracktag('event', 'clickout')">CTA</button>
<button onclick="tracktag('event', 'conversion', { payout: '29.90', txid: 'order_998' })">Confirm</button>

Send intermediate signals keyed by clickId:

<button onclick="tracktag('event', 'update', { step: 'checkout' })">Checkout</button>

update fires an Image pixel to {endpoint} with caller params. The SDK injects clid, _event=update, _output=pixel, _cb (non-overridable). Repeatable.

The function stub buffers every tracktag(...) call into .q. Once the SDK loads, it drains .q serially behind the first config, then replaces the stub with the real function — so later tracktag(...) calls enqueue and run immediately.

Tracking is best-effort: a failed Click fetch, any event before config resolves, or a malformed response is silently skipped — it never throws to the page. Pass debug: true on config to log activity and failures to the console.

clid-provided mode (clid in the URL)

When a visitor arrives via a tracker redirect, the click id is already in the page URL as ?clid=... (e.g. https://lander.example.com/?clid=abc123). The SDK detects it and skips the config Click request — no fetch, the clid is used directly. The same config({ endpoint }) call and CTA wiring serve both arrival types; publishers change nothing. Per-event behavior in this mode is noted in the API table below.

Cross-domain note: the SDK reads clid only from the page URL — a cookie set on the tracker's own domain isn't readable by the lander (same-origin). The click id must arrive via the URL, or via a first-party tracker script on the lander that re-exposes it.

API

declare function tracktag(command: 'config', opts: Options): void;
declare function tracktag(command: 'event', name: string, params?: EventParams): void;

interface Options {
  endpoint: string;
  debug?: boolean;
}

interface Click {
  clickId: string;
  clickUrl?: string;
  clickTrackers?: string[];
  postbackUrl?: string;
}

type EventParams = Record<string, string | number | boolean>;

Event names:

| Name | Behavior | | ------------- | ----------------------------------------------------------------------------------- | | 'clickout' | Fire clickTrackers beacons (sendBeacon → Image → fetch), then navigate to clickUrl. No-op when absent/empty. | | 'conversion'| Fire Image pixel to postbackUrl with caller params. Repeatable. | | 'update' | Fire Image pixel to endpoint with caller params. Repeatable. |

In clid-provided mode (?clid= in the URL) clickout instead navigates to {endpoint}?clid={clid} and conversion/update no-op — see clid-provided mode.

Development

pnpm install
pnpm test              # Vitest + jsdom
pnpm run typecheck
pnpm run lint
pnpm run build         # IIFE, IIFE-min
pnpm run example       # local Lander fixture + mock server on :5173

See AGENTS.md for the full design spec, invariants, and contribution rules.

License

MIT