Core ​
The core is plain TypeScript with zero framework dependencies. Use it in vanilla JS, a Node script, or any framework.
ts
import { createTracker } from 'attribution-kit'
const tracker = createTracker({
ttlDays: 30,
storageKey: 'attribution_touches',
})
// read the URL + stored touches and record a new touch if needed
tracker.init()
// get the current data
const data = tracker.getData()
// get the payload ready to send with an API request
const payload = tracker.getPayload()How resolution works ​
On each init(), the tracker:
- Parses any UTM parameters from the current URL.
- If no UTM is present, falls back to the
referrer. - If neither exists, records the source as
"Direct". - Skips recording if the same source was already seen that day (deduplication).
- Drops touches older than
ttlDays.
See all available options in the API reference.