# Installation via \<script> tag

## How to install it?

**1. Add Telegram Mini Apps Analytics to your project**

Include the Telegram Mini Apps Analytics script in the header of your HTML document. This script will allow you to track and analyze user interactions effectively.

```html
<!-- Add Telegram Analytics script to HTML head -->
<script 
    async 
    src="https://tganalytics.xyz/index.js" 
    onload="initAnalytics()" 
    type="text/javascript"
></script>
```

Alternative solution (not recommended)

```html
<!-- Add Telegram Analytics script to HTML head -->
<script
    async 
    src="https://unpkg.com/@telegram-apps/analytics@latest/dist/index.js"
    onload="initAnalytics()"  
    type="text/javascript"
></script>
```

#### 2. Initialize the **Telegram Mini Apps Analytics** SDK

Once you have your unique access token and analytics identifier (if not, see [Preparations](https://docs.tganalytics.xyz/sdk/preparations) page), you can initialize the Telegram Analytics SDK in your code. This step is crucial for enabling the tracking of events without repeatedly transferring the token.

```html
<script>
    function initAnalytics() {
      window.telegramAnalytics.init({
        token: 'YOUR_TOKEN',
        appName: 'ANALYTICS_IDENTIFIER',
      });
    }
</script>
```

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