If you run ads in CIS markets, you have seen this in your analytics reports:
utm_campaign=%D0%90%D0%BA%D1%86%D0%B8%D1%8F
That is a Cyrillic UTM value (Акция) percent-encoded into garbage. It splits one campaign into unreadable duplicates and makes grouping impossible. I kept solving this — and a few other small marketing-math problems — over and over, so I extracted the logic into two tiny, zero-dependency packages.
1. utm-translit — clean UTM builder
npm: utm-translit · also on pub.dev as utm_translit for Dart/Flutter.
It does three things every UTM value needs: lowercase (analytics are case-sensitive, CPC ≠ cpc), transliterate Cyrillic (Акция → aktsiya), and strip unsafe characters while keeping dynamic placeholders like {keyword}.
const { buildUtm, preset } = require('utm-translit');
buildUtm('example.com', {
source: 'yandex',
medium: 'cpc',
campaign: 'Летняя Акция',
});
// → https://example.com/?utm_source=yandex&utm_medium=cpc&utm_campaign=letnyaya_aktsiya
buildUtm('https://shop.ru/sale', { ...preset('yandex'), campaign: 'summer' });
// keeps {keyword} placeholders intact
There is a CLI too:
npx utm-translit example.com -s yandex -m cpc -c "Летняя Акция"
2. np-marketing-metrics — the formulas, once
npm: np-marketing-metrics. Pure functions for the metrics every marketing dashboard recomputes: ad performance, ROMI/ROAS, social engagement, and A/B incrementality with real statistical significance.
const { adMetrics, romi, incrementality } = require('np-marketing-metrics');
adMetrics({ impressions: 10000, clicks: 200, cost: 4000, conversions: 20 });
// { ctr: 2, cpc: 20, cpm: 400, cpa: 200, cr: 10 }
romi({ visits: 1000, conversions: 50, cost: 10000, revenue: 30000 });
// { romi: 200, roas: 3, cr: 5, drr: 33.33…, profit: 20000, cpa: 200 }
incrementality({ n1: 10000, c1: 600, n2: 10000, c2: 500, confidence: 95 });
// two-proportion z-test: p-value, confidence interval, verdict, iROAS
The incrementality function uses a proper two-proportion z-test (with normCDF/invNormCDF helpers exported), so you get a p-value and confidence interval, not just a lift number.
Why I built these
They are the open-source cores of the free marketing engineering tools I maintain — the web versions if you prefer a UI are the UTM generator and the ROMI calculator. Returning plain numbers (not formatted strings) keeps the libraries locale-agnostic.
Both are MIT, zero-dependency, and tested. Issues and PRs welcome.
Author: Nikolai Polyakov — performance marketing & analytics.
Top comments (0)