# Installation via NPM package (https://docs-fpm2731fy-ton-core-docs.vercel.app/llms/ecosystem/tma/analytics/install-via-npm/content.md)



## How to install it? [#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](/llms/ecosystem/tma/analytics/preparation/content.md) page) and installed the 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 [#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)

* [Supported events](/llms/ecosystem/tma/analytics/supported-events/content.md)
