# Track clicks, forms and sales

Pick a button on your site, use a ready-made event, or add one line of code. Crustat shows how often it happened and how many visitors did it.

Source: https://crustat.com/docs/tracking/events-and-goals

## Where events live

An event is a moment you care about, like a sign-up click or a form sent. Each one on your site's **Events** tab shows:

- **Times**: how often it happened.
- **People**: how many people did it.
- **Of all visitors**: the share of the period's visitors who did it.

Switch between **Today**, **7 days** and **30 days** at the top. Owners and admins can add, change and remove events.

File downloads are counted with no setup. They show under one **Downloads** line: click it to see each file. To stop counting them, turn off **Count downloads** on the Events tab. See [What Crustat tracks on its own](https://crustat.com/docs/tracking/automatic-tracking).

## The easy way: pick it on your site

1. On the **Events** tab, press **Pick on my site**. Your site opens in a new tab with a small Crustat bar.
2. Click the button or link you want to track. Need to get to another page first? Press **Move around the site**, then **Back to picking**.
3. Check the name, choose **On every page** or **Only on this page**, and save.

With more than one domain, Crustat first asks **Pick on which domain?** The tracking line must be on the page.

## Ready-made events

Press **Add an event**. Under **Ready-made, one click**, press **Add** and these start right away:

- **Every form sent**: each form under its own name, like "Form: newsletter".
- **Broken pages (404)**: visits to a page that doesn't exist, as "Page not found".
- **Read to the end** and **Read half the page**: how far down people scroll.
- **Stayed a minute**: a page kept on screen for a minute.

**Thank-you page**, **Pricing page**, **Sign-up clicks** and **Contact clicks** need one detail from you first, so they have a **Set up** button.

## Set one up by hand

Press **Add an event**, then **Describe it**. In **Set up an event**, choose what should be recorded:

- **A click on a button or link.** Find it by its words ("Start free trial", capitals or not), by where the link goes (`/signup`), or by a CSS selector.
- **A form being sent.** Any form, or one form by its CSS selector. What people type is never read.
- **A visit to a page.** Paste its address, like `/thank-you`.
- **Scrolling down a page.** All the way, or a percentage from 1 to 100. It's recorded once per page view.
- **Staying on a page a while.** From 1 to 3600 seconds, while the page is on screen.
- **A broken page (404).** A page whose title says 404 or "not found".

Then choose **Where?**: **On every page**, **On one page**, or **On a group of pages** (like every address starting with `/blog/`). If the site has more than one domain, you can limit it to one under **On which domain?**

New and changed events reach your site within about 5 minutes and apply from then on, not to past visits.

## For developers: send events from code

**A button or link.** Add `data-crustat-event` with a name. Every click on it, or on anything inside it, is recorded.

```html
<button data-crustat-event="Sign up">Sign up</button>
```

**A form.** Put the attribute on the `<form>` itself. It's recorded when the form is sent.

```html
<form action="/contact" data-crustat-event="Contact">…</form>
```

**Anything else.** Call `crustat` with a name where it happens. It takes one thing: the name. In a click handler or anything else that runs after the page has loaded, check that Crustat is there first:

```js
window.crustat && crustat("Purchase");
```

**Calls that run as the page loads**, like an inline script on your thank-you page, can come before the Crustat script is ready. For those, paste this line above your Crustat tag:

```html
<script>window.crustat=window.crustat||function(){(window.crustat.q=window.crustat.q||[]).push(arguments)}</script>
```

It holds early calls and sends them right after the first page view. With it, a plain `crustat("Purchase")` works anywhere.

Nothing is sent on `localhost`, or from a browser where you've turned on [Ignore my visits](https://crustat.com/docs/tracking/ignore-your-visits).

## Limits

- **Names** are 1 to 60 characters. "Sign up" and "Signup" are two different events, so keep names the same everywhere.
- **Up to 50** events set up on the **Events** tab per site. Events from code and downloads aren't part of that limit.
- **Name only.** An event carries its name and the page, nothing else. A sale shows how many times it happened, not how much it was worth.

## Turn an event into a goal

Next to any event, choose **Make it a goal** to set a target for the month or the week. See [Set goals](https://crustat.com/docs/tracking/goals).
