> For the complete documentation index, see [llms.txt](https://docs.tganalytics.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tganalytics.xyz/sdk/installation-via-less-than-script-greater-than-tag.md).

# 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](/sdk/preparations.md) 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](/supported-events.md)

***

### Navigation:

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.tganalytics.xyz/sdk/installation-via-less-than-script-greater-than-tag.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
