Tracker reference
The script tag, its attributes, the React component and what is sent.
The tracker is the small script that counts visits on your site, okidoki.js. It is under 1.5 KB gzipped, loads after your page, and writes nothing to the visitor's browser.
#The tag
<script defer data-site="ok_your_site_key" src="https://okidoki.sh/js/okidoki.js"></script>#Attributes
| Attribute | Required | What it does |
|---|---|---|
data-site | Yes | Your public site key, like ok_7f3kq2m9xa. Without it the script does nothing |
defer | Recommended | Loads the script after the page, so it never slows the page down |
data-local | No | Also runs on localhost and 127.0.0.1, which are skipped by default. Only for testing |
data-api | No | Where events are sent. Defaults to /api/event on okidoki.sh, and to e next to the script when it loads from your own address, like /x7f3k/e. See Count visitors with ad blockers |
data-exclude | No | Paths to leave out, separated by commas, like /account,/admin. Each one also covers every page below it. No page views or automatic events are sent there, but your own window.okidoki calls still are, so you can count a purchase inside a signed-in area. To leave a page out completely, use private pages (below) |
On a <video> or a YouTube or Vimeo <iframe>, data-okidoki-video="Product tour" names the video in the video report.
#Private pages and addresses with personal details
Some addresses hold things about a person, like /customers/anna@example.com or /order/1048576. Okidoki keeps the page but never the identifier: before the script sends anything, a part of the address with an @ or six digits in a row becomes [id]. Okidoki's servers then mask more, like UUIDs, phone numbers and long codes, before anything is stored. So /order/1048576 shows up in your reports as /order/[id], and every order page is counted as one page.
To store nothing at all for part of your site, open Settings → Site and add it under Private pages, like /account. Each path covers every page below it. Nothing is stored there: no page views, no time on page, no automatic events and none of your own window.okidoki calls. It works for every way of installing, with no change on your site, and takes effect within a minute.
#The JavaScript API
The script adds one function, window.okidoki, to send a custom event:
window.okidoki(name, target);| Argument | Required | |
|---|---|---|
name | Yes | The event name, like Signup. Up to 64 characters |
target | No | Extra detail, like a plan or a file. Up to 512 characters |
Or skip JavaScript and add data-okidoki-event="Signup" to any element. See Custom events.
#What it counts by itself
- Page views, including page changes in single-page apps through
pushState,replaceStateand the back button. - Time on page, only while the page is visible.
- Clicking on, when a visitor follows a link within your site.
- Outbound links, downloads, email and phone links, and form submissions.
- Videos: starts, a quarter, half and three quarters watched, and the end, for
<video>players and YouTube and Vimeo embeds. Only pages with a video load the small add-onv.jsthat counts them. See Videos. - How far each page is read: the deepest point reached, as a share of the page. See Reading and site search.
- Load time of the first page of each visit.
- Problems: pages that say "404" or "not found", JavaScript errors (at most three per page load) and rage clicks, three quick clicks on the same thing. See Warnings.
#What it sends
The script sends small JSON messages with fetch, as plain text, so no extra request is needed first. Each one is sent without credentials (credentials: 'omit'), so your site's own cookies never travel with it, even when the script runs on your own address. There are three kinds:
| Kind | When | Contains |
|---|---|---|
| Page view | A page opens | The page address, the referrer, the window width, and whether a visit starts here |
| Engagement | The page is hidden or closed | The path, the page title (once per page view), visible milliseconds, how far the page was read, and whether the visitor clicked on. The first page of a visit also sends its load time, and repeats its address and referrer so it can be filtered by source |
| Event | A tracked click or form, a problem on the page, or your own event | The path, the event name and, for some events, a target. On the first page of a visit it also repeats that page's address and referrer, so a goal reached there can be counted per campaign or email |
On our side the address is cut down to its path, the five UTM tags and a cleaned site search, the browser language to its main language, the referrer to its site name, and the browser string to browser, system and device. Only the latest title of each page is kept, so lists can show "Pricing" instead of "/pricing". Titles with an email address, a long number or a greeting are dropped, and pages that look like someone's own (account, order, checkout, profile) never get one. Country and region come from our hosting platform. The rest is thrown away before anything is stored. See Privacy and GDPR.
#What it never does
- It never sets cookies or uses local storage, session storage or IndexedDB.
- It never creates a visitor ID or fingerprints the browser.
- It never reads what is typed into forms.
- It never records the screen, mouse movements or how someone scrolls. It keeps only the deepest point reached on each page.
#The React component
import { Okidoki } from 'okidoki-analytics';
<Okidoki site="ok_your_site_key" />It adds the same script tag once, with defer. Props: site (required) and src (defaults to https://okidoki.sh/js/okidoki.js). See React and Next.js.
#Content Security Policy
If your site has a Content Security Policy, allow the script and the place it sends to:
script-src https://okidoki.sh;
connect-src https://okidoki.sh;Counting visitors with ad blockers from your own subdomain? Allow that address too, like https://stats.example.com. Through a proxy on your own address, 'self' already covers it.
The install sentence asks your AI tool to do this for you when it finds a Content Security Policy.
#Performance
The script is cached for an hour by browsers and served with defer, so it loads after your page is ready. On pages with a video it also loads v.js, about 2 KB, from the same place. It adds a few event listeners and sends a beacon per page view and engagement. It does not change your page.