> ## 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.

# Javascript

> Learn how to track your first visit & event using Javascript.

## Pre-Requisites

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

## 1. Install

With this line of code in your **index.html**, inside the **body** or **head** tag, you can already collect analytics like `Page Visits`, `Referrers`, `Avarage Session Time` and many more.

```javascript javascript theme={null}
<script defer data-workspace="workspace_id" 
src="https://cdn.jsdelivr.net/npm/litlyx-js@latest/browser/litlyx.js">
</script>
```

## 2. Collect Custom Events

To customize your experience, add the following line in each function you desire. There is no limit to the number of events.

```javascript javascript theme={null}
Lit.event("your_event_name");
```

If you want to exercise more control over your events, you can use the `metadata` field. In your dashboard, you can group them in the `Events` tab with the `Event Metadata Analyzer`.

```javascript javascript theme={null}
Lit.event("your_event_name", metadata: { 
  'type': 'MAIN_CTA', 
  'priority': 0.9
});
```

## HTML example code

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

## 3. Your turn now!

Use litlyx in your html website at ease.
