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

@click-chutney/clickanalytics

v0.0.4

Published

Simplified analytics library inspired by Vercel Analytics - privacy-first, lightweight tracking

Readme

ClickAnalytics

A lightweight, privacy-first analytics library inspired by Vercel Analytics. Simple, powerful, and framework-agnostic.

Features

  • 🚀 Zero Configuration - Works out of the box with minimal setup
  • 🔒 Privacy-First - No personal data collection, GDPR compliant
  • Lightweight - < 5KB gzipped, minimal performance impact
  • 🎯 Framework Agnostic - Works with React, Next.js, Vue, Svelte, or vanilla JS
  • 🛡️ TypeScript Support - Full type safety included
  • 🔧 Flexible - Multiple integration methods to fit your workflow
  • 📊 Real-time - Events sent immediately for accurate tracking

Quick Start

React/Next.js

npm install @click-chutney/clickanalytics

Add the Analytics component to your app:

import { Analytics } from '@click-chutney/clickanalytics/react';

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        {children}
        <Analytics trackingId="your-tracking-id" />
      </body>
    </html>
  );
}

Track custom events with the hook:

import { useAnalytics } from '@click-chutney/clickanalytics/react';

function MyComponent() {
  const analytics = useAnalytics();
  
  const handleClick = () => {
    analytics.event('button_click', { button: 'signup' });
  };
  
  return <button onClick={handleClick}>Sign Up</button>;
}

Vanilla JavaScript

npm install @click-chutney/clickanalytics
import { inject } from '@click-chutney/clickanalytics';

// Initialize
inject({ trackingId: 'your-tracking-id' });

// Track events
import { event } from '@click-chutney/clickanalytics';
event('button_click', { button: 'signup' });

CDN/Script Tag

<script src="https://unpkg.com/@click-chutney/clickanalytics/dist/clickanalytics.min.js"></script>
<meta name="clickanalytics-tracking-id" content="your-tracking-id">

<script>
  // Automatically initialized from meta tag
  // Track custom events
  caPV(); // page view
  caEV('button_click', { button: 'signup' }); // custom event
  caID('user-123'); // identify user
</script>

Installation Methods

Method 1: React/Next.js Component

Perfect for React applications with automatic page view tracking.

// 1. Install the package
npm install @click-chutney/clickanalytics

// 2. Add to your root layout
import { Analytics } from '@click-chutney/clickanalytics/react';

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        {children}
        <Analytics trackingId="your-tracking-id" />
      </body>
    </html>
  );
}

// 3. Use the hook for custom events
import { useAnalytics } from '@click-chutney/clickanalytics/react';

function MyComponent() {
  const analytics = useAnalytics();
  
  return (
    <button onClick={() => analytics.event('click', { button: 'cta' })}>
      Click me
    </button>
  );
}

Method 2: Inject Function (Any Framework)

Great for Vue, Svelte, Angular, or vanilla JS applications.

import { inject, event, pageview } from '@click-chutney/clickanalytics';

// Initialize once in your app
inject({ 
  trackingId: 'your-tracking-id',
  debug: true 
});

// Track events anywhere
event('user_signup', { method: 'email' });
pageview('/dashboard');

Method 3: Script Tag (No Build Step)

Perfect for static sites, WordPress, or any HTML page.

<!DOCTYPE html>
<html>
<head>
  <meta name="clickanalytics-tracking-id" content="your-tracking-id">
  <script src="https://unpkg.com/@click-chutney/clickanalytics/dist/clickanalytics.min.js"></script>
</head>
<body>
  <button onclick="caEV('button_click', { button: 'signup' })">
    Sign Up
  </button>
</body>
</html>

API Reference

React Component

<Analytics 
  trackingId="your-id"           // Required: Your tracking ID
  debug={true}                   // Optional: Enable debug logging
  disableInDev={true}           // Optional: Disable in development
  apiUrl="/api/analytics"       // Optional: Custom API endpoint
  beforeSend={(event) => event} // Optional: Modify events before sending
/>

React Hook

const analytics = useAnalytics();

analytics.pageview('/custom-page', 'Custom Title');
analytics.event('custom_event', { key: 'value' });
analytics.identify('user-123');
analytics.flush(); // Force send queued events

Inject Function

import { inject, event, pageview, identify } from '@click-chutney/clickanalytics';

// Initialize
inject({
  trackingId: 'your-tracking-id',
  debug: false,
  disableInDev: true,
  apiUrl: '/api/analytics',
  beforeSend: (event) => {
    // Modify or filter events
    return event;
  }
});

// Track events
pageview(); // Auto-tracks current page
pageview('/custom-path', 'Custom Title');
event('button_click', { button: 'signup' });
identify('user-123');

Script Tag Globals

When using the script tag, these functions are available globally:

caPV(url?, title?)              // Page view
caEV(eventName, properties?)    // Custom event  
caID(userId)                   // Identify user

Configuration

Environment Variables

Set your tracking ID using environment variables:

# React/Next.js
NEXT_PUBLIC_CLICKANALYTICS_ID=your-tracking-id

# Or alternative names
NEXT_PUBLIC_CLICKCHUTNEY_ID=your-tracking-id
CLICKANALYTICS_TRACKING_ID=your-tracking-id

Meta Tag

Add a meta tag to auto-initialize:

<meta name="clickanalytics-tracking-id" content="your-tracking-id">

Advanced Configuration

inject({
  trackingId: 'your-tracking-id',
  debug: true,                    // Enable console logging
  disableInDev: true,            // Disable in development
  apiUrl: '/api/analytics',      // Custom API endpoint
  beforeSend: (event) => {       // Filter/modify events
    // Add custom data
    event.customData = { version: '1.0' };
    
    // Block certain events
    if (event.event === 'spam') return false;
    
    return event;
  }
});

Event Types

Page Views

Automatically tracked when using React component or inject function.

// Manual page view tracking
pageview('/dashboard', 'Dashboard');

Custom Events

Track any user interaction or business event.

event('button_click', {
  button: 'signup',
  location: 'header',
  user_type: 'anonymous'
});

event('purchase', {
  item_id: 'prod_123',
  price: 29.99,
  currency: 'USD'
});

User Identification

Associate events with specific users.

identify('user-123');

// All subsequent events will include this user ID
event('page_view'); // Will include userId: 'user-123'

Integration Examples

Next.js App Router

// app/layout.tsx
import { Analytics } from '@click-chutney/clickanalytics/react';

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        {children}
        <Analytics />
      </body>
    </html>
  );
}

// app/page.tsx
import { useAnalytics } from '@click-chutney/clickanalytics/react';

export default function HomePage() {
  const analytics = useAnalytics();
  
  return (
    <button onClick={() => analytics.event('cta_click')}>
      Get Started
    </button>
  );
}

Vue.js

// main.js
import { inject } from '@click-chutney/clickanalytics';

inject({ trackingId: 'your-tracking-id' });

// component
import { event } from '@click-chutney/clickanalytics';

export default {
  methods: {
    trackClick() {
      event('button_click', { component: 'header' });
    }
  }
}

Svelte

// app.js
import { inject } from '@click-chutney/clickanalytics';

inject({ trackingId: 'your-tracking-id' });

// Component.svelte
<script>
  import { event } from '@click-chutney/clickanalytics';
  
  function handleClick() {
    event('button_click', { button: 'subscribe' });
  }
</script>

<button on:click={handleClick}>Subscribe</button>

WordPress

<!-- Add to theme header.php or use a plugin -->
<meta name="clickanalytics-tracking-id" content="your-tracking-id">
<script src="https://unpkg.com/@click-chutney/clickanalytics/dist/clickanalytics.min.js"></script>

<!-- Track events in your theme -->
<button onclick="caEV('button_click', { button: 'contact' })">
  Contact Us
</button>

Development

Disable analytics during development:

// Automatically disabled in development
inject({
  trackingId: 'your-tracking-id',
  disableInDev: true // Default: true
});

// Or use environment detection
const isDev = process.env.NODE_ENV === 'development';
if (!isDev) {
  inject({ trackingId: 'your-tracking-id' });
}

Privacy & GDPR

ClickAnalytics is designed to be privacy-first:

  • ✅ No personal data collection
  • ✅ No cross-site tracking
  • ✅ No fingerprinting
  • ✅ IP addresses used only for geolocation, not stored
  • ✅ GDPR compliant by design
  • ✅ No third-party cookies

Troubleshooting

Common Issues

1. Events not appearing

  • Check your tracking ID is correct
  • Verify network requests in browser dev tools
  • Enable debug mode: inject({ debug: true })

2. Multiple initializations

  • Only call inject() once in your app
  • Use reset() to reinitialize if needed

3. TypeScript errors

  • Ensure you're importing from the correct path
  • React components: @click-chutney/clickanalytics/react
  • Inject functions: @click-chutney/clickanalytics

Debug Mode

Enable debug logging to troubleshoot issues:

inject({
  trackingId: 'your-tracking-id',
  debug: true
});

This will log all events and API calls to the console.

Getting Your Tracking ID

  1. Sign up at clickchutney.com
  2. Create a new project
  3. Copy your tracking ID from the dashboard
  4. Add it to your environment variables or configuration

License

MIT License - see LICENSE file for details.

Support