Skip to content

Configuration

Akayashuu edited this page Jun 12, 2026 · 2 revisions

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.

data-* options (snippet)

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

Settings in detail

  • data-domain — always set it explicitly. Without it, Takt infers the domain from location.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 write data-outbound (no need for ="true").
  • data-exclude-localhost — enabled by default. Pass "false" to also measure localhost and private IPs.
  • Do Not Track — the snippet always respects the DNT header; there is no attribute to disable it. To drive this guardrail, use the npm respectDnt option.
<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-localhost flag protects your visitors' privacy, and the snippet always respects Do Not Track. Only disable these guardrails if you know exactly why.

init() options (npm)

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.

npm-only options

These settings have no data-* equivalent; they are only available in an npm integration:

Option Type Default Role
enabled boolean true Stops all sending when false (handy in staging)
debug boolean false Logs every event to the console
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

By default, the query string and hash are stripped from every URL before sending. The snippet always applies this scrubbing; trackQuery/queryParams/scrubUrl let you tune it on the npm side. See Privacy.

Name mapping: data-exclude-localhostexcludeLocalhost. The semantics are identical between snippet and npm for the shared settings.


Source: github.com/vskstudio/takt-core · npm @vskstudio/takt-core

Takt — @vskstudio/takt-core


React · Vue · Svelte wrappers: see the docs site.

Clone this wiki locally