Installation and initialization
Attention. We discontinued the development of new versions of the AppMetrica Windows SDK.
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
Copied to clipboard
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>
Copied to clipboard
<Application ... xmlns:metrica="using:Yandex.Metrica"> ... <Application.Resources> ... <metrica:YandexMetricaActivator x:Key="String" ApiKey="API_key" /> ... </Application.Resources> ... </Application>
Copied to clipboard
The library starts sending events after the app is launched.
Initialize the library in the application code using the method:
The library begins sending events after the method is called.YandexMetrica.Activate(string API_key)
Copied to clipboard
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>
Add to the Package.appxmanifest
file the following permissions in code mode:
<Capabilities>
...
<Capability Name="internetClient" />
<DeviceCapability Name="location" />
...
</Capabilities>