OakData is one small snippet plus, optionally, a call to say who each visitor is. This page is the quickest path from an empty project to real data in your dashboard. Prefer your framework's guide? Jump straight to it:
In a hurry? Hand the whole setup to your AI coding agent - paste this and give it your public key when asked:
The four steps
Create a project and copy your key
In the OakData dashboard, create a project for your site. Open its settings and copy the public key - it starts with oak_pub_ and is safe to ship in the browser.
Two keys, two jobs
Public keys (oak_pub_…) can only write events and belong in your site. Secret keys (oak_sec_…) stay on your server and are the only keys that can read data back through the REST API and MCP server.
Add the SDK to your site
Install the package, then initialise it once as early as possible - or follow your framework's guide above for the exact place to put it:
npm i oakdata-jsimport oak from 'oakdata-js'
oak.init('oak_pub_xxxxxxxxxxxxxxxxxxxxxxxx', {
api_host: 'https://oakdata.co',
})That boots the tracker: pageviews fire on load and autocapture records clicks and form submits. No build step? Load it from a CDN via a script tag instead. Capturing events from your backend? Use oakdata-node.
Identify your users (recommended)
Once someone signs in, tell OakData who they are. Their earlier anonymous activity is stitched onto the identified profile - see identity resolution.
oak.identify(user.id, { email: user.email, name: user.name })
// …and on sign-out:
oak.reset()Watch the first events land
Load a page on your site, then open Livein the dashboard. Your visit should appear within a second or two, with its country, device, and page. That's it - you're tracking.
Nothing showing up?
A wrong key, localhost, or an ad-blocker can all swallow events. Work through Not seeing data - it covers each cause in order.