Skip to content

The Snippet

Akayashuu edited this page Jun 19, 2026 · 2 revisions

The snippet

One line of script, zero dependencies, ≤ 1 kB gzip. Paste it into the <head> and Takt starts measuring your pages — privacy-first.

Installation

Place the script as high as possible in the <head>, before your content. The defer attribute guarantees it never blocks rendering, and data-domain ties the data to the right site in your dashboard.

<script defer src="https://cdn.jsdelivr.net/npm/@vskstudio/takt-core/dist/takt.js" data-domain="example.com"></script>

The snippet automatically excludes localhost and private IPs, and respects Do Not Track. So in local development you won't see anything come through — that's expected.

Need to sample traffic, keep specific query params, or toggle a guardrail? The base snippet reads optional data-* attributes (data-sample-rate, data-track-query, data-query-params, data-respect-dnt, data-enabled) for all of that — see Configuration.

As soon as it loads, Takt sends a pageview for the current page and then tracks every navigation after that, including inside a SPA (History API). You don't need to wire anything else for basic audience measurement.

Tracking an event

Beyond page views, fire custom events from your code. The global window.takt(name, options) function is available immediately, even before the script has finished loading (calls are queued).

// A simple named event
window.takt('Signup')

// With properties to segment later
window.takt('Signup', { props: { plan: 'pro' } })

A few typical use cases:

  • Interaction — Clicking a CTA, opening a modal, submitting a form.
  • Revenue — Attach an amount to a purchase with $ to track revenue.
  • Journey — Onboarding or funnel steps to spot friction points.
  • Downloads — PDFs, exports, outbound links — enabled with a single data-* attribute.

What's next


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