> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ton.org/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.ton.org/feedback

```json
{
  "path": "/ecosystem/tma/analytics/install-via-script",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# 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 theme={"theme":{"light":"github-light-default","dark":"dark-plus"},"languages":{"custom":["/resources/grammars/tolk.tmLanguage.json","/resources/grammars/tlb.tmLanguage.json","/resources/grammars/fift.tmLanguage.json","/resources/grammars/tasm.tmLanguage.json","/resources/grammars/func.tmLanguage.json"]}}
<!-- 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 theme={"theme":{"light":"github-light-default","dark":"dark-plus"},"languages":{"custom":["/resources/grammars/tolk.tmLanguage.json","/resources/grammars/tlb.tmLanguage.json","/resources/grammars/fift.tmLanguage.json","/resources/grammars/tasm.tmLanguage.json","/resources/grammars/func.tmLanguage.json"]}}
<!-- 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 (TO DO link)  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 theme={"theme":{"light":"github-light-default","dark":"dark-plus"},"languages":{"custom":["/resources/grammars/tolk.tmLanguage.json","/resources/grammars/tlb.tmLanguage.json","/resources/grammars/fift.tmLanguage.json","/resources/grammars/tasm.tmLanguage.json","/resources/grammars/func.tmLanguage.json"]}}
<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)

* [Supported events](/ecosystem/tma/analytics/supported-events)
