Skip to content

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:

  1. Parses any UTM parameters from the current URL.
  2. If no UTM is present, falls back to the referrer.
  3. If neither exists, records the source as "Direct".
  4. Skips recording if the same source was already seen that day (deduplication).
  5. Drops touches older than ttlDays.

See all available options in the API reference.

Released under the MIT License.