Docs
Open Okidoki

Custom events

Count a button or anything else with one attribute or one line of JavaScript.

Okidoki counts outbound links, downloads, email and phone links and forms by itself. To count anything else, like a button, give it a name. Custom events show up in Clicks, downloads and forms and can be used as goals.

#With one attribute

Add data-okidoki-event to any element. A click on it, or on anything inside it, counts as the event:

HTML
<button data-okidoki-event="Signup">Create account</button>
<a href="/demo" data-okidoki-event="Book demo">Book a demo</a>

This works on any site, and an AI builder can add it for you. Paste something like:

For your AI builder
Add the attribute data-okidoki-event="Signup" to the "Create account" button. Do not change anything else.

#With JavaScript

Call window.okidoki with the name of the event:

JavaScript
window.okidoki('Signup');

In a React app, or anywhere the script may not have loaded yet, check that it is there first:

TypeScript
window.okidoki?.('Purchase');

You can pass a second value, the target, like a plan name or a file. It shows under the event in the report:

JavaScript
window.okidoki('Upgrade', 'plus-yearly');

#Naming events

  • Use short, plain names: Signup, Book demo, Purchase. Names are shown as they are.
  • Use the same name everywhere you count the same thing.
  • Names can be up to 64 characters, and targets up to 512.

#What is sent

An event sends its name, the target if there is one, and the path of the page it happened on. Nothing about the visitor. See the Tracker reference.