tigr-js
v0.2.1
Published
tigr analytics SDK for any website — plain JS, drop-in <script> tag or npm, with auto-capture of user behaviour.
Maintainers
Readme
tigr-js
The plain-JavaScript tigr analytics SDK for any website —
static HTML, server-rendered, jQuery, whatever. Same auto-capture core as
tigr-react / tigr-vue, but with zero build step on the host site.
Install — the one-liner (plain HTML)
Drop this in your <head>, before your own scripts:
<script src="/tigr.js" data-api-key="tigr_pk_live_your_key"></script>That's it. On load it auto-starts and begins capturing pageviews, rage clicks, scroll depth, errors and page-leaves. No other code needed.
Manual events
The SDK is on window.tigr:
<script>
window.tigr.setUser('user_123', { name: 'Ada', plan: 'pro' })
window.tigr.track('signup_completed', { plan: 'pro' })
// on logout:
window.tigr.reset()
</script>Load
tigr.jsbefore any inline script that callswindow.tigr, so the global exists when your code runs. (A plain<script src>in<head>runs synchronously — nodeferneeded.)
Script-tag options (data-*)
| Attribute | Effect |
| ------------------- | -------------------------------------------------------- |
| data-api-key | Required to auto-start. Your project API key. |
| data-host | Override the ingestion host (default: tigr's CDN). |
| data-auto-capture | "false" to disable all automatic capture. |
| data-dev-mode | "true" to make the SDK a full no-op (local dev). |
| data-debug | "true" to log events + flushes to the console. |
Install — as a module (bundlers / npm)
import { tigr } from 'tigr-js'
tigr.initialize('tigr_pk_live_...')
tigr.setUser('user_123', { name: 'Ada' })
tigr.track('signup_completed', { plan: 'pro' })For advanced use (multiple clients, custom config) the core is exported too:
import { createTigr, TigrClient } from 'tigr-js'.
Build
npm install
npm run buildOutputs to dist/:
index.js/index.cjs/index.d.ts— the npm packagetigr.js— the standalone browser build for the<script>tag
