takt

Installation

Three ways to add Takt to your site, depending on your stack.

CDN

A single <script> tag. Ideal for a static site, plain HTML, WordPress, Webflow…

npm

An import in your bundle. Ideal for a React, Vue, Svelte, Solid, Angular, Astro, Next app…

Queue

Captures takt() calls fired before the script is ready.

The simplest method: a single tag in the <head>. The file is served from a global CDN, cached and versioned.

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

unpkg works too: replace cdn.jsdelivr.net/npm with unpkg.com.

To pin a specific version (and avoid any surprise on update), pin it in the URL: @vskstudio/[email protected]/dist/takt.js.

npm

If you already have a bundler, install the package and drive Takt from code. This is the preferred path for framework applications.

pnpm add @vskstudio/takt-core
# or: npm install @vskstudio/takt-core
# or: yarn add @vskstudio/takt-core
# or: bun add @vskstudio/takt-core
import { init, track } from '@vskstudio/takt-core'

// Once, at app startup: fires the initial pageview,
// wires up SPA navigation and creates the shared instance.
init({ domain: 'example.com' })

// Everywhere else: emit your events.
track('Signup', { props: { plan: 'pro' } })

All init() options are detailed in the configuration.

Framework wrappers

Using React, Vue, Svelte, Solid, Angular or Astro? Rather than driving the core by hand, reach for the dedicated wrapper — component, hooks/composables, directive/action and web component included, all SSR-safe:

Each builds on @vskstudio/takt-core and exposes an /element subpath for the <takt-analytics> web component, usable even outside your framework.

On the server side, Takt also integrates with PHP: render the snippet straight into your HTML and send server-to-server (S2S) events, via three Composer packages published on Packagist:

In Node.js, the core ships its own server-to-server client: the @vskstudio/takt-core/server entry, documented on the Node.js (server) page.

Queue (calls before load)

Because the script is loaded with defer, it may not be ready when your code calls takt(). This shim creates a queue: calls are stored then replayed once the script loads. No event is lost.

<script>
  window.takt = window.takt || function () { (window.takt.q = window.takt.q || []).push(arguments) }
</script>
With the CDN snippet, this queue is already handled for you: you can call window.takt(...) immediately. This shim is only useful if you load the script in a custom way.