# 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](https://docs.okidoki.sh/reports/events) and can be used as [goals](https://docs.okidoki.sh/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:

```text title="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:

```js
window.okidoki('Signup');
```

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

```ts
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:

```js
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.

> [!WARNING]
> Never put personal data in an event name or target, like an email address, a name or an order number tied to a customer. Okidoki is built to hold no personal data, and that only stays true if events do not carry any.

## 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](https://docs.okidoki.sh/tracker).

