Installation and initialization

The AppMetrica SDK can be used for tracking mobile and desktop applications on Windows.

Step 1. Integrating the library

The AppMetrica library is provided as a NuGet package.

To connect the library, use the graphical interface or the command line of the NuGet package manager:
Install-Package Yandex.Metrica -Version 3.5.1

Step 2. Initializing the library

Attention. In the desktop application, before initializing the library, specify a folder for storing service files using the YandexMetricaFolder.SetCurrent(string path) method. The maximum volume of locally stored data is 2 MB.

Initialize the library in the app using one of the methods shown below:

Make changes to the Application item of the App.xaml file:
<Application 
    ...
    xmlns:metrica="clr-namespace:Yandex.Metrica;assembly=Yandex.Metrica">
    ...
    <Application.Resources>
        ...
        <metrica:YandexMetricaActivator
            x:Key="String"
            ApiKey="API_key" />
        ...
    </Application.Resources>
    ...
</Application>

The library starts sending events after the app is launched.

What is the API key?

The API key is a unique application identifier that is issued in the AppMetrica web interface during app registration.

Make sure you have entered it correctly.

Step 3. Setting up access permissions

Configure the app's Capabilities depending on the platform.
Note. For .NET applications setting permissions is not necessary.

Add to the Properties/WMAppManifest.xml file the following permissions:

<Capabilities>
    ...
    <Capability Name="ID_CAP_IDENTITY_DEVICE" />
    <Capability Name="ID_CAP_LOCATION" />
    <Capability Name="ID_CAP_NETWORKING" />
    ...
</Capabilities>