Quickstart
Install datacub and see your first event in a few minutes.
1. Get your project key
Open Settings, Integrations in the dashboard. Your project key starts with pk_live_ (or pk_test_ while you build). It is public and safe in client code. More about keys.
In Settings, General, add your website's domain to the sites allowed to send, or your app's bundle ID or package name to the apps allowed to send. datacub refuses events from anywhere else.
2. Add the SDK
Paste this in your HTML <head> (in Next.js, TanStack Start or SvelteKit, see where the head is). It loads the SDK from datacub and defines the global datacub:
<script>
(function (w, d, src) {
var q = (w.datacub = w.datacub || [])
;['init', 'track', 'identify', 'reset'].forEach(function (n) {
q[n] = function () { q.push([n].concat([].slice.call(arguments))) }
})
var s = d.createElement('script'); s.async = true; s.src = src; d.head.appendChild(s)
})(window, document, 'https://ingest.datacub.example/v1/sdk/datacub-0.4.0.min.js')
datacub.init('pk_live_YOUR_PROJECT_KEY')
</script>On localhost, use your test key (pk_test_): datacub refuses live keys from localhost. Every project comes with one, marked Test in Settings, Integrations. More about keys.
Not on npm. Do not install
@datacub/web, or anything else under@datacub, from npm: that npm name does not belong to datacub. The React Native SDK is not published yet: contact the datacub team for early access.
3. That is the install
datacub tracks page views, sessions, sources and clicks from the first page view. There is no banner to wire. If you want to wait for your visitors' consent first, see asking for consent. What the SDK collects, and how to turn parts off, is in install the web SDK.
4. Track one thing that matters
Pick the moment your product works for someone, and track it after it succeeds:
async function createProject(name: string) {
const project = await api.createProject(name)
datacub.track('project_created', { template: project.template })
return project
}How to choose and name events.
5. Check it arrived
In Settings, Integrations, choose Check the connection and open your site or app: datacub tells you the moment the first event lands. Realtime shows events as they arrive. Nothing there? On localhost the SDK prints a console warning for every call it refuses. See troubleshooting.
Working with an AI coding agent?
Paste the AI setup prompt into Claude Code, Cursor, Codex or ChatGPT. It reads your app, installs the SDK, proposes a short event plan and waits for your yes.