takt

Events & payload

Each event is posted to the endpoint as compact JSON. The keys are deliberately short — every byte counts on the wire — and frozen: Takt ingestion depends on them, do not rename them.

Anatomy of the payload

KeyMeaningExample
nevent name (pageview for views)"Signup"
ddomain"example.com"
upage URL"https://example.com/pricing"
rreferrer"https://google.com"
wviewport width (px)1440
pprops (object, omitted if empty){ "plan": "pro" }
$revenue { a: amount, c: currency }{ "a": "29", "c": "EUR" }

A pageview therefore looks like this on the wire:

{ "n": "pageview", "d": "example.com", "u": "https://example.com/pricing", "r": "", "w": 1440 }

And a custom event with props:

{ "n": "Signup", "d": "example.com", "u": "https://example.com/signup", "r": "", "w": 1440, "p": { "plan": "pro" } }

Properties (props)

Props split a single event into sub-categories you can analyze in the dashboard. Keep them simple and low-cardinality (plan, country, button type) — no unique identifier and no personal data.

window.takt('Signup', { props: { plan: 'pro', method: 'google' } })
Never send personal data in props (email, identifier, name). Takt is designed to stay anonymous — high-cardinality props break this model and aggregation.

props are sanitized before sending: non-string values are coerced to strings, empty values ('', null, undefined) are dropped, and limits are enforced (the event still sends, a console warning fires once):

LimitValue
Number of keys30 max (extras dropped)
Key length64 characters
Value length1024 characters

Revenue ($)

To track revenue, attach an amount and a currency. The amount is a string (to avoid floating-point imprecision) and the currency is an ISO 4217 code (uppercased on send).

// snippet (global window.takt)
window.takt('Purchase', {
  props: { plan: 'pro' },
  revenue: { amount: '29', currency: 'EUR' }
})

On the wire, this becomes the compact key $: { "a": "29", "c": "EUR" }.

Revenue is validated: the amount must match \d+(\.\d{1,2})? (integer or up to 2 decimals) and the currency be a 3-letter code. If either is malformed, the revenue is dropped (the rest of the event still sends) with a console warning.

In an npm integration, revenue goes through the instance returned by init() — see the API reference.

See also

  • Configuration — endpoint and flags that generate automatic events (outbound links, files).
  • Privacy — when an event is not sent.