---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://appmetrica.yandex.com.tr/docs/en/sdk/unity/analytics/quick-start.md
  - https://appmetrica.yandex.com.tr/docs/ru/sdk/unity/analytics/quick-start.md
---
> **Documentation Index:** Fetch the complete configuration index at https://appmetrica.yandex.com.tr/docs/en/llms.txt

# Installation and initialization

AppMetrica Unity is a plugin for the [Unity3d](http://docs.unity3d.com/) platform. It includes the AppMetrica SDK support for Android and iOS.

This section describes the steps to enable and initialize the AppMetrica Unity plugin:

## Step 1. Enable the AppMetrica Unity plugin {#integration}

{% list tabs %}

- OpenUPM

  Add the following dependencies to [Packages/manifest.json](https://docs.unity3d.com/Manual/upm-manifestPrj.html):

     ```json translate=no
     {
       "scopedRegistries": [
         {
           "name": "package.openupm.com",
           "url": "https://package.openupm.com",
           "scopes": [
             "com.google.external-dependency-manager",
             "io.appmetrica.analytics"
           ]
         }
       ],
       "dependencies": {
         "com.google.external-dependency-manager": "1.2.187",
         "io.appmetrica.analytics": "6.10.0"
       }
     }
     ```

- UPM (GitHub)

  1. Follow the [documentation](https://github.com/googlesamples/unity-jar-resolver/tree/master?tab=readme-ov-file#getting-started) to enable External Dependency Manager.

  2. Add AppMetrica Unity Plugin to the dependencies in [Packages/manifest.json](https://docs.unity3d.com/Manual/upm-manifestPrj.html):

     ```json translate=no
     {
       "dependencies": {
         "io.appmetrica.analytics": "https://github.com/appmetrica/appmetrica-unity-plugin.git#v6.10.0"
       }
     }
     ```

{% endlist %}

## Step 2. Initialize the library {#initialization}

We recommend activating AppMetrica with [RuntimeInitializeOnLoadMethodAttribute](https://docs.unity3d.com/ScriptReference/RuntimeInitializeOnLoadMethodAttribute.html).

Create a static method with the `[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]` attribute and activate AppMetrica using the `AppMetrica.Activate()` method.

Example:

```csharp translate=no
using Io.AppMetrica;
using UnityEngine;

public static class AppMetricaActivator {
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
    private static void Activate() {
        AppMetrica.Activate(new AppMetricaConfig("APIKey") {
            FirstActivationAsUpdate = !IsFirstLaunch(),
        });
    }

    private static bool IsFirstLaunch() {
        // Implement logic to detect whether the app is opening for the first time.
        // For example, you can check for files (settings, databases, and so on),
        // which the app creates on its first launch.
        return true;
    }
}
```

## Learn more {#learn-more}

- [Sending E-commerce events](https://appmetrica.yandex.com.tr/docs/en/sdk/unity/analytics/unity-operations.md#send-ecommerce)
- [Sending Revenue data](https://appmetrica.yandex.com.tr/docs/en/sdk/unity/analytics/unity-operations.md#send-revenue)
- [Sending Ad Revenue data](https://appmetrica.yandex.com.tr/docs/en/sdk/unity/analytics/unity-operations.md#send-adrevenue)
- [How do I enable user location sending?](https://appmetrica.yandex.com.tr/docs/en/troubleshooting/troubleshooting.md#region)

<!-- source: en/_includes/feedback-button-3.md -->
If you didn't find the answer you were looking for, you can use the feedback form to submit your question. Please describe the problem in as much detail as possible. Attach a screenshot if possible.

<a href="../../../troubleshooting/feedback-new">
  <span class="button">Contact support</span>
</a>

<a href="../../../troubleshooting/feedback-docs">
  <span class="button">Suggest an improvement for documentation</span>
</a>
<!-- endsource: en/_includes/feedback-button-3.md -->
