> ## Documentation Index
> Fetch the complete documentation index at: https://docs.litlyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Events

> Litlyx is a powerful tool that allows you to track custom events with minimal setup.

## Pre-Requisites

Before proceeding, ensure you sign up on [Litlyx](https://dashboard.litlyx.com/) and create a new workspace.

## Minimal Setup

<Note>
  Make sure you have initialized the library in your entry point.
</Note>

Add the following line of code, in each key `function` you would like to track.

```javascript theme={null}
Lit.event('click-on-buy');
```

## Handle Metadata

Sometimes just an `event name` isn't enough. If you want to add more control to your data, you can use the `metadata` field. Like this:

```javascript theme={null}
Lit.event('click_on_buy_item', {
  metadata: {
    'product-name': 'Coca-Cola',
    'price': 1.50,
    'currency': 'EUR'
  }
});
```

## HTML example code

```html theme={null}
<button onclick="Lit.event('click-on-buy')">Buy</button>
```

## Function example code

```javascript theme={null}
myFunction () {
  // your existing code...
  Lit.event('my-function-name');
}
```

## Ready to go!

Analyze all yours `custom events` on the cloud dashboard.

* Understand how users interact with your website by creating `Custom Funnels`.
* Analyze where your users come from and trigger an event with the `User Flow`.
* Check events metadata with our `Events Metadata Analyzer`.

## Test your first event

Curious to see how Litlyx works with events? Simply use the cURL command below to send a test event. Just replace `workspace_id` with your actual workspace ID in your terminal.

```bash theme={null}
curl -X POST "https://broker.litlyx.com/event" \
  -H "Content-Type: application/json" \
  -d '{
    "pid": "workspace_id",
    "name": "testEvent1",
    "metadata": "{\"test\": \"something\"}",
    "website": "something",
    "userAgent": "something"
  }'
```
