# Installation via script tag (https://docs-dmpho5eos-ton-core-docs.vercel.app/llms/ecosystem/tma/analytics/install-via-script/content.md)



## How to install it? [#how-to-install-it]

<div className="fd-steps">
  <div className="fd-step">
    ### Add Telegram Mini Apps Analytics to your project [#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>
    ```
  </div>

  <div className="fd-step">
    ### Initialize the SDK [#2-initialize-the-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
    <script>
        function initAnalytics() {
          window.telegramAnalytics.init({
            token: 'YOUR_TOKEN',
            appName: 'ANALYTICS_IDENTIFIER',
          });
        }
    </script>
    ```
  </div>
</div>

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