Installation
Three ways to add Takt to your site, depending on your stack.
CDN
<script> tag. Ideal for a static site, plain HTML, WordPress, Webflow…npm
Queue
takt() calls fired before the script is ready.CDN (recommended)
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.
@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:
- React —
@vskstudio/takt-react(provider, hooks,<TaktEvent>). - Vue —
@vskstudio/takt-vue(component, composable, directive, plugin). - Svelte —
@vskstudio/takt-svelte(component,use:taktEventaction). - Solid —
@vskstudio/takt-solid(component, hooks,<TaktEvent>). - Angular —
@vskstudio/takt-angular(provideTakt(), service,[taktEvent]directive). - Astro —
@vskstudio/takt-astro(integration,<Takt />component).
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:
- PHP —
vskstudio/takt-core-php(framework-agnostic core:SnippetRenderer+TaktS2S client). - Laravel —
vskstudio/takt-laravel(@taktBlade directive,Taktfacade, publishable config). - Symfony —
vskstudio/takt-symfony(takt()Twig function, autowiredTaktservice).
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> window.takt(...) immediately. This shim is only useful if you load the script in a custom way.