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

np-marketing-metrics

v1.0.0

Published

Pure functions for core marketing metrics: ad performance (CTR/CPC/CPM/CPA/CR), ROMI/ROAS, social engagement (ER/ERR), and A/B incrementality testing with statistical significance. Zero dependencies.

Readme

np-marketing-metrics

Pure functions for the core marketing & advertising metrics: ad performance, ROMI/ROAS, social engagement, and A/B incrementality testing with statistical significance. Zero dependencies, Node + browser.

npm version license zero dependencies

This is the open-source math behind the free marketing engineering calculators at nepolyakov.ru. Functions return plain numbers, so you format them for any locale yourself. Prefer a UI? Use the live tools linked below.

Install

npm install np-marketing-metrics

Usage

const { adMetrics, romi, engagement, incrementality } = require('np-marketing-metrics');
// ESM: import { adMetrics } from 'np-marketing-metrics';

Ad performance — CTR, CPC, CPM, CPA, CR

Mirror of the ad metrics calculator.

adMetrics({ impressions: 10000, clicks: 200, cost: 4000, conversions: 20 });
// { ctr: 2, cpc: 20, cpm: 400, cpa: 200, cr: 10 }

ROMI / ROAS

Mirror of the ROMI calculator.

const r = romi({ visits: 1000, conversions: 50, cost: 10000, revenue: 30000 });
// { romi: 200, roas: 3, cr: 5, drr: 33.33…, profit: 20000, cpa: 200 }
romiVerdict(r.romi); // 'good'

Social engagement — ER / ERR

Mirror of the ER & ERR calculator.

engagement({ likes: 80, comments: 15, shares: 3, saves: 2, followers: 1000, reach: 500 });
// { engagement: 100, er: 10, err: 20, viewRate: 50, likeRate: 16, commentRate: 3, ... }
erBenchmark(5000); // { good: 10, low: 5, label: 'норма для 5–10К: 10–20%' }

A/B incrementality testing

Mirror of the incrementality / geo-lift calculator. Two-proportion z-test with p-value, confidence interval, incremental conversions and iROAS.

incrementality({ n1: 10000, c1: 600, n2: 10000, c2: 500, confidence: 95, value: 1000, cost: 50000 });
// {
//   cr1: 6, cr2: 5, absLift: 1, relLift: 20,
//   z: …, pValue: <0.05, significant: true, verdict: 'significant-positive',
//   ciLow: …, ciHigh: …, incremental: 100, iroas: 2
// }

Statistics helpers normCDF(z) and invNormCDF(p) are also exported.

API summary

| Function | Returns | | --- | --- | | adMetrics(input) | { ctr, cpc, cpm, cpa, cr } | | romi(input) | { romi, roas, cr, drr, profit, cpa } | | romiVerdict(romi) | 'loss' \| 'break-even' \| 'modest' \| 'good' | | engagement(input) | { engagement, er, err, erImpressions, viewRate, likeRate, commentRate } | | erBenchmark(followers) | { good, low, label } \| null | | incrementality(input) | full z-test result object |

Related

License

MIT © Nikolai Polyakov