> For the complete documentation index, see [llms.txt](https://evntaly.gitbook.io/evntaly/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://evntaly.gitbook.io/evntaly/sdks/web.md).

# Web

The Evntaly Web SDK is a lightweight JavaScript library designed to simplify event tracking, user identification, and analytics on web applications.

{% embed url="<https://github.com/Evntaly/evntaly-web>" fullWidth="false" %}

## Installation and Initialization

The Evntaly Web SDK can be added directly to your web application using a CDN.

```html
<script async src="https://cdn.evntaly.com/evntaly-web-v1.0.7.js"></script>
<script>
   window.evsq = window.evsq || [];
   window.evntaly = window.evntaly || ((...args) => window.evsq.push(args));
   window.evntaly("init", "YOUR_API_TOKEN" , "YOUR_PROJECT_NAME");
</script>
```

## Automatic Event Tracking

Automatically track events by adding `data-event` attributes to HTML elements.

```html
<button
  data-event="Upgraded Plan"
  data-user-id="user-123"
  data-channel="billing"
  data-icon="💰"
  data-tag-plan="Pro"
  data-tag-period="Monthly"
  data-tag-price="9.99"
  data-payload-country="Egypt">
    Upgrade to Pro
</button>
```

## Manual Event Tracking

For custom event tracking, use the **track** method.

```html
<script>
window.evntaly('track', {
    title: "Manual Event",
    description: "Manually triggered event",
    user: { id: "user-123" },
    feature: "manual-feature",
    type: "Button Click",
    tags: { source: "dashboard" },
    message: "Event successfully tracked.",
    notify: true,
    icon: "🔥",
    sessionID: "session-12345",
    topic: "@Dashboard"
});
</script>
```

## User Identification

Identify a user to associate events with a specific profile.

```html
<script>
window.evntaly('identifyUser', {
    id: "user-123",
    email: "user@example.com",
    full_name: "John Doe",
    organization: "ExampleCorp",
    data: {
        role: "admin",
        plan: "Pro",
        location: "USA",
        timezone: "America/New_York"
    }
});
</script>
```

## Enabling and Disabling Tracking

Control event tracking globally.

```html
<script>
window.evntaly('disableTracking');  // Disables tracking
window.evntaly('enableTracking');   // Enables tracking
</script>
```

## Methods&#x20;

| Method            | Description                               | Example Usage                              | Available Since |
| ----------------- | ----------------------------------------- | ------------------------------------------ | --------------- |
| `init`            | Initializes the SDK with API credentials. | `window.evntalySet(token, projectName)`    | v1.0.0          |
| `track`           | Manually tracks a custom event.           | `window.evntaly('track', eventData)`       | v1.0.0          |
| `identifyUser`    | Identifies a user for analytics.          | `window.evntaly('identifyUser', userData)` | v1.0.0          |
| `disableTracking` | Disables all event tracking.              | `window.evntaly('disableTracking')`        | v1.0.0          |
| `enableTracking`  | Enables all event tracking.               | `window.evntaly('enableTracking')`         | v1.0.0          |
| `trackPageView`   | Automatically tracks page views.          | `window.evntaly('trackPageView')`          | Soon            |

## Best Practices

* **Initialize early:** Always initialize the SDK as soon as possible.
* **Avoid sensitive data:** Do not pass sensitive personal data directly to the SDK.
* **Test thoroughly:** Ensure the event tracking aligns with your analytics goals.

## Troubleshooting

* **Events not sending:** Check if the SDK is correctly initialized with valid API tokens.
* **Network errors:** Make sure the network allows outbound requests to `https://evntaly.com`.

***

## Support

For more help, contact support at **<support@evntaly.com>**.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://evntaly.gitbook.io/evntaly/sdks/web.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
