Installation via NPM package

How to install and use via <script> tag

How to install it?

1. Install the NPM package in your project

npm install @telegram-apps/analytics
yarn add @telegram-apps/analytics
pnpm add @telegram-apps/analytics

2. Add Telegram Mini Apps Analytics in code

Once you have your unique access token (if not, see 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

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


Last updated