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

@clocsy/track

v1.0.0

Published

Clocsy Brand Intelligence SDK — domain verification, pageview intelligence, CPA conversion tracking, and affiliate identity linking.

Readme

@clocsy/track

Clocsy Brand Intelligence SDK — domain verification, pageview intelligence, CPA conversion tracking, and affiliate identity linking.

npm version License: MIT Zero Dependencies

Why

If you're using Clocsy to grow your business, the SDK connects your live website to the Clocsy intelligence engine. It handles:

  • Domain verification — auto-fires when your site loads, granting the "Website Verified" badge in your dashboard
  • Pageview intelligence — tracks navigation, referrers, UTM parameters, and screen dimensions
  • CPA conversion tracking — fires conversion events that trigger affiliate payouts and campaign attribution
  • Affiliate identity linking — de-duplicates users across devices for accurate referral tracking
  • SPA support — auto-detects pushState/popstate route changes in React, Next.js, Vue, etc.

Install

npm install @clocsy/track
yarn add @clocsy/track
pnpm add @clocsy/track

Quick Start

import { init, track, identify } from '@clocsy/track';

// 1. Initialize once at app startup
init({
  projectId: 'proj_abc123',   // from Clocsy Brand Settings
  token: 'tok_xyz',           // from Clocsy Brand Settings
});

// 2. Track a conversion event
track('signup_complete', { value: 49.00, currency: 'USD' });

// 3. Identify a user for affiliate attribution
identify('[email protected]', { plan: 'pro' });

Framework Examples

React (Vite / CRA)

// src/main.tsx
import { init } from '@clocsy/track';

init({
  projectId: 'proj_abc123',
  token: 'tok_xyz',
});

Next.js App Router

// app/providers.tsx
'use client';

import { useEffect } from 'react';
import { init } from '@clocsy/track';

export function ClocsyProvider({ children }: { children: React.ReactNode }) {
  useEffect(() => {
    init({
      projectId: 'proj_abc123',
      token: 'tok_xyz',
    });
  }, []);

  return <>{children}</>;
}
// app/layout.tsx
import { ClocsyProvider } from './providers';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        <ClocsyProvider>{children}</ClocsyProvider>
      </body>
    </html>
  );
}

Next.js Pages Router

// pages/_app.tsx
import { useEffect } from 'react';
import { init } from '@clocsy/track';

export default function App({ Component, pageProps }) {
  useEffect(() => {
    init({ projectId: 'proj_abc123', token: 'tok_xyz' });
  }, []);

  return <Component {...pageProps} />;
}

Vue 3

// main.ts
import { createApp } from 'vue';
import { init } from '@clocsy/track';
import App from './App.vue';

init({ projectId: 'proj_abc123', token: 'tok_xyz' });

createApp(App).mount('#app');

Nuxt 3

// plugins/clocsy.client.ts
import { init } from '@clocsy/track';

export default defineNuxtPlugin(() => {
  init({ projectId: 'proj_abc123', token: 'tok_xyz' });
});

API Reference

init(config: ClocsyConfig): void

Initialize the SDK. Call once at app startup. Automatically fires a verification ping and an initial pageview.

| Option | Type | Default | Description | |--------|------|---------|-------------| | projectId | string | required | Your Clocsy project ID | | token | string | required | Domain verification token | | apiBase | string | https://api.clocsy.com | Override API base URL | | disableAutoPageview | boolean | false | Skip auto pageview on init | | debug | boolean | false | Log beacons to console |

track(event: string, meta?: TrackMeta): void

Track a conversion event. If a CPA campaign exists for this event, Clocsy automatically credits the referring affiliate.

track('purchase', { value: 99.00, currency: 'USD' });
track('trial_start');
track('app_install', { platform: 'ios' });

identify(identity: string, meta?: IdentifyMeta): void

Link the current session to a user identity for cross-device de-duplication.

identify('[email protected]', { plan: 'enterprise' });

pageview(): void

Manually fire a pageview beacon. Auto-fires on init and on SPA route changes by default.

// Custom route change handling
router.afterEach(() => {
  pageview();
});

SSR Safety

All SDK methods are server-side rendering (SSR) safe. When imported in a server environment (Next.js Server Components, Nuxt SSR, Node.js), all methods become silent no-ops — no errors, no warnings, no crashes.

// This is safe in a Server Component — it simply does nothing
import { init } from '@clocsy/track';
init({ projectId: 'proj_abc123', token: 'tok_xyz' });
// ↑ No-op on server, active on client

How It Works

  1. Verification Ping: On init(), the SDK sends a POST to /sdk/verify with your project ID and token. This grants the "Website Verified" badge in your Clocsy dashboard.

  2. Pageview Tracking: The SDK captures the current URL, path, referrer, document title, screen dimensions, and UTM parameters. It monkey-patches history.pushState and history.replaceState to auto-track SPA route changes.

  3. Conversion Tracking: When you call track('event_name', meta), the SDK fires a POST to /sdk/track. If a CPA campaign exists with a matching event, Clocsy processes the conversion and credits the referrer.

  4. Identity Linking: identify() fires a POST to /sdk/identify to link the current anonymous session to a known user. This prevents duplicate affiliate payouts across devices.

Bundle Size

  • Zero runtime dependencies
  • ESM + CJS dual output
  • Under 2KB gzipped
  • Tree-shakeable (sideEffects: false)

Requirements

  • Node.js 18+ (uses native fetch)
  • Modern browsers (Chrome 42+, Firefox 39+, Safari 10.1+, Edge 14+)

License

MIT © Clocsy