-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
Takt is configured in two equivalent ways: via data-* attributes on the snippet tag (CDN), or via init() options (npm). Both drive the same settings.
| Attribute | Effect | Default |
|---|---|---|
data-domain |
Site identifier in your dashboard | location.hostname |
data-endpoint |
Event ingestion endpoint | /api/event |
data-outbound |
Tracks clicks on outbound links (flag) | off |
data-files |
Tracks file downloads (flag) | off |
data-exclude-localhost="false" |
Also measures localhost / private IPs | excluded |
data-enabled="false" |
Kill-switch — the tracker does nothing | enabled |
data-respect-dnt="false" |
Opt out of the Do Not Track guard | respected |
data-sample-rate="0.5" |
Send only this fraction (0–1) of events |
1 (all) |
data-track-query |
Keep the full query string and hash | stripped |
data-query-params="utm_source,utm_medium" |
Keep only these query params | none |
-
data-domain— always set it explicitly. Without it, Takt infers the domain fromlocation.hostname, which breaks aggregation if your site responds on several hosts (www, staging, test domain). -
data-endpoint— changes the URL events are posted to. Useful behind a proxy or a dedicated ingestion subdomain. -
data-outbound/data-files— these are flags: their mere presence activates them, regardless of value. Just writedata-outbound(no need for="true"). -
data-exclude-localhost— enabled by default. Pass"false"to also measure localhost and private IPs. -
data-enabled="false"— total kill-switch: no listener is attached and nothing is ever sent. -
Privacy & sampling — the snippet respects Do Not Track and strips the query string by default. Tune these on the tag itself:
data-respect-dnt="false"(opt out of the DNT guard),data-sample-rate="0.5"(send a fraction of events),data-track-query(keep the full query + hash),data-query-params="utm_source,utm_medium"(keep only an allowlist). Same semantics as the npm options below.
<script
defer
src="https://cdn.jsdelivr.net/npm/@vskstudio/takt-core/dist/takt.js"
data-domain="example.com"
data-outbound
data-files
></script>The
data-exclude-localhostflag protects your visitors' privacy, and the snippet always respects Do Not Track. Only disable these guardrails if you know exactly why.
In the npm version, these same settings are passed as an object to init() (in camelCase for booleans):
import { init } from '@vskstudio/takt-core'
init({
domain: 'example.com', // required in practice
endpoint: '/api/event', // optional
outbound: true, // tracks outbound links
files: true, // tracks downloads
excludeLocalhost: true, // default
respectDnt: true // default
})init() creates a shared instance, fires an automatic pageview and wires up SPA navigation. Call it only once, at application startup.
These tune privacy, sampling and autocapture. enabled, sampleRate, trackQuery and queryParams also have a snippet data-* form (above); debug and scrubUrl are npm-only.
| Option | Type | Default | Role |
|---|---|---|---|
enabled |
boolean |
true |
Stops all sending when false (handy in staging) |
debug |
boolean |
false |
Logs every event to the console (npm-only) |
sampleRate |
number |
1 |
Samples sent events (0–1) |
trackQuery |
boolean |
false |
Keeps the query string as-is |
queryParams |
string[] |
— | Allowlist of query params to keep |
scrubUrl |
(url) => url |
— | Custom URL scrubbing (npm-only) |
tagged |
boolean |
false |
Custom events from data-takt-event elements (snippet: data-auto="tagged") |
By default, the query string and hash are stripped from every URL before sending. trackQuery/queryParams/scrubUrl (npm) or data-track-query/data-query-params (snippet) tune it. See Privacy.
Name mapping:
data-exclude-localhost→excludeLocalhost. The semantics are identical between snippet and npm for the shared settings.
Source: github.com/vskstudio/takt-core · npm @vskstudio/takt-core
- Home
- The-Snippet
- Installation
- Configuration
- Vanilla-JS
- Events-and-Payload
- Privacy
- Widgets
- API-Reference
React · Vue · Svelte wrappers: see the docs site.