﻿<head><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4357510538660394"
     crossorigin="anonymous"></script></head>---
title: Custom Events
description: "Send custom events from your site with track(): signups, purchases, CTA clicks, and actions beyond pageviews."
sidebar:
  label: Custom Events
seo:
  title: Track custom events with Clics track() API
---

Custom events let you measure actions beyond pageviews: signups, purchases, feature usage, or any interaction that matters to your product.

Pageviews are tracked automatically once the [tracker script](/installation-guides) is installed. Custom events are sent explicitly from your code with `track()`.

## Before you start

1. Add the Clics tracker script to your site (see [Installation Guides](/installation-guides)
2. Install the npm package (recommended for TypeScript projects):

```bash
npm add @clicsdev/tracker
```

The script tag is required. The npm package only adds a typed `track()` helper. It does not replace the script.

## What gets tracked

| Type | How | Event name |
| --- | --- | --- |
| Pageviews | Automatic on load and SPA navigation | `pageview` |
| Custom events | `track()` in your code | Any name you choose |

Each event includes the page URL, referrer, UTM parameters, and your project ID. Properties you pass to `track()` are merged into the event payload.

## `track(name, props?)`

Send a custom event from the browser.

```typescript
import { track } from "@clicsdev/tracker";

track("signup");
track("purchase", { plan: "pro", billing: "annual" });
track("cta_click", { location: "hero", variant: "primary" });
```

| Argument | Type | Description |
| --- | --- | --- |
| `name` | `string` | Event name (e.g. `signup`, `purchase`) |
| `props` | `Record<string, unknown>` | Optional properties attached to the event |

`track()` only works in the browser and requires the tracker script to be loaded first. If the script is missing, a warning is logged to the console and the event is not sent.

## Naming conventions

Use short, lowercase names with underscores:

- `signup`, `login`, `purchase`
- `cta_click`, `feature_used`, `trial_started`

Keep names stable over time. [goals](/dashboard/goals) and [funnels](/dashboard/funnels) match on the exact event name.

Property values should be strings, numbers, or booleans. Use consistent keys across events (e.g. always `plan`, not `plan` on one event and `tier` on another).

## Examples

### Button click

```tsx
import { track } from "@clicsdev/tracker";

export function SignupButton() {
  return (
    <button
      type="button"
      onClick={() => track("signup", { plan: "pro" })}
    >
      Sign up
    </button>
  );
}
```

### Form submission

```typescript
function onSubmit(data: FormData) {
  track("contact_form", {
    topic: data.get("topic"),
    source: "pricing_page",
  });
}
```

### After a successful checkout

```typescript
track("purchase", {
  amount: 49,
  currency: "USD",
  plan: "pro",
});
```

## Analyze events in the dashboard

There is no separate Events tab. Use the **Events** card on [Overview](/dashboard) (and [AI Analytics](/dashboard/ai-analytics)) for top event names, filter Overview by **Event**, or inspect properties on a visit under [Sessions](/dashboard/sessions). See [Events](/dashboard/events) for the full dashboard guide.

## Use events in goals and funnels

- **Goals**: create an event goal in **Configure → Goals** and set the event