# Installation via NPM package

## How to install it?

**1. Install the NPM package in  your project**

```shell
npm install @telegram-apps/analytics
```

```shell
yarn add @telegram-apps/analytics
```

```sh
pnpm add @telegram-apps/analytics
```

**2. Add Telegram Mini Apps Analytics in code**

Once you have your unique access token (if not, see [Preparations](https://docs.tganalytics.xyz/sdk/preparations) page) and install NPM package, you can initialize the Telegram Analytics SDK in your code. To ensure that all events are collected correctly, you must initialize the SDK before the application starts rendering. For example, in react applications, before calling the `render()` function

```jsx
import TelegramAnalytics from '@telegram-apps/analytics'

TelegramAnalytics.init({
    token: 'YOUR_TOKEN',
    appName: 'ANALYTICS_IDENTIFIER',
});
```

### Supported Events

After initializing the **Telegram Analytics**, you are all set to transfer the data, gain insights, and improve user engagement. (99% of them will be tracked **automatically** without manual control)

[Read more about supported events](https://docs.tganalytics.xyz/supported-events)

***

### Navigation:

* [Overview](https://docs.tganalytics.xyz/overview)
* SDK installation:
  * [preparations](https://docs.tganalytics.xyz/sdk/preparations)
  * [via \<script> tag](https://docs.tganalytics.xyz/sdk/installation-via-less-than-script-greater-than-tag)
  * [via NPM package](https://docs.tganalytics.xyz/sdk/installation-via-npm-package)
* [API docs](https://docs.tganalytics.xyz/api)
* [Supported events](https://docs.tganalytics.xyz/supported-events)
* [Bot](https://docs.tganalytics.xyz/managing-integration)
* [Demo app](https://github.com/Dimitreee/demo-dapp-with-analytics)
