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

attribu

v1.0.1

Published

Lightweight revenue attribution and analytics tracker

Readme

attribu

Official Attribu SDK for web apps. Use this if you prefer npm packages over the script tag.

Installation

npm install attribu

Quick Start

Same API as in the Attribu docs: use initAttribu once, then call trackPageview(), track(), identify(), and trackPayment().

import { initAttribu } from 'attribu';

const attribu = await initAttribu({
  websiteId: 'your-website-id',
  domain: 'yourdomain.com', // optional, defaults to current hostname
});

// Track page views
attribu.trackPageview();

// Track custom events
attribu.track('button_click', { button: 'signup' });

// Identify users
attribu.identify({ user_id: 'user_123', email: '[email protected]', plan: 'pro' });

// Track payments (email-based)
attribu.trackPayment({ email: '[email protected]' });

// Or Stripe session-based
attribu.trackPayment({ stripe_session_id: 'cs_live_123' });

// Reset visitor identity (e.g. on logout)
attribu.reset();

With React / Next.js

// lib/analytics.ts
import { initAttribu } from 'attribu';

let attribu: Awaited<ReturnType<typeof initAttribu>> | null = null;

export async function getAnalytics() {
  if (!attribu) {
    attribu = await initAttribu({
      websiteId: process.env.NEXT_PUBLIC_ATTRIBU_WEBSITE_ID!,
      domain: process.env.NEXT_PUBLIC_ATTRIBU_DOMAIN,
    });
  }
  return attribu;
}

Then in your components:

import { getAnalytics } from '@/lib/analytics';

export default function SignupButton() {
  const handleSignup = async () => {
    const analytics = await getAnalytics();
    analytics.track('signup', { plan: 'free', source: 'homepage' });
  };

  return <button onClick={handleSignup}>Sign Up</button>;
}

API

initAttribu(config) -> Promise<AttribuInstance>

Initialize the SDK. Returns a client with all tracking methods. SSR-safe (returns no-ops on the server).

Config (AttribuConfig)

{
  websiteId: string;            // Required: Your Attribu website ID
  domain?: string;              // Optional: Defaults to current hostname
  src?: string;                 // Optional: Custom script URL (for self-hosted instances)
  allowLocalhost?: boolean;     // Optional: Allow tracking on localhost (default: false)
  allowedHostnames?: string[];  // Optional: Hostnames for cross-domain tracking
  disablePayments?: boolean;    // Optional: Disable auto payment detection (default: false)
  disableAutoPageview?: boolean; // Optional: Disable initial pageview (default: false)
}

By default, tracking is silently disabled on localhost, file:// protocol, inside iframes, and for bots/headless browsers. Set allowLocalhost: true for local development.

attribu.trackPageview() -> void

Track a page view. Uses window.location.href including query params, UTMs, and ad click IDs. SPA navigation (pushState/popstate) is automatically tracked. Duplicate pageviews for the same URL within 60 seconds are automatically skipped.

attribu.track(eventName, properties?) -> void

Track a custom event.

attribu.track('add_to_cart', { product: 'Pro Plan', price: 49 });

attribu.identify(data) -> void

Identify a logged-in user. user_id is required.

attribu.identify({ user_id: 'user_123', name: 'John', email: '[email protected]' });

attribu.trackPayment(data) -> void

Track a payment. Include email or stripe_session_id for attribution.

attribu.trackPayment({ email: '[email protected]' });
attribu.trackPayment({ stripe_session_id: 'cs_live_123' });

attribu.getVisitorId() -> string | null

Get the current visitor ID (from attribu_visitor_id cookie).

attribu.getSessionId() -> string | null

Get the current session ID (from attribu_session_id cookie).

attribu.getTrackingParams() -> { _att_vid, _att_sid }

Get visitor and session IDs for cross-domain tracking.

attribu.buildCrossDomainUrl(url) -> string

Append visitor/session tracking params to a URL for cross-domain navigation.

const url = attribu.buildCrossDomainUrl('https://other-domain.com/signup');
// => 'https://other-domain.com/signup?_att_vid=abc-123&_att_sid=s456-789'

On the receiving domain, initAttribu automatically picks up the params and restores the visitor/session.

attribu.reset() -> void

Reset visitor identity (e.g. on logout). Clears visitor and session cookies.

Script Tag Alternative

If you prefer not to use npm, add the script tag instead:

<script
  defer
  data-website-id="your-website-id"
  data-domain="yourdomain.com"
  src="https://attribu.tech/js/script.js"
></script>

License

MIT