You can use the Windows SDK for mobile and desktop applications. The SDK is provided as a NuGet package. Install the NuGet package manager, if you have not installed it yet.
To get started, add the AppMetrica library to the app and configure it:
Add the following access permissions to WMAppManifest :
Use one of the methods below to start collecting application statistics.
If you are connecting the SDK to a desktop application, before you start collecting statistics, you must set the folder for storing files using the Yandex.Metrica.YandexMetricaFolder.SetCurrent(string path) method.
Add an element describing the metrica:YandexMetricaActivator resource and specify:
ApiKey is a unique application identifier that is issued in the AppMetrica web interface during app registration. After the app has been registered, ApiKey is available in editing mode.
Example of contents of the App.xaml file:
<Application ... xmlns:metrica="clr-namespace:Yandex.Metrica;assembly=Yandex.Metrica"> ... <Application.Resources> ... <metrica:YandexMetricaActivator x:Key="YandexMetricaActivator" ApiKey="your application's API key" /> ... </Application.Resources> ... </Application>
Use the method YandexMetrica.Activate(string apiKey):
YandexMetrica.Activate(apiKey: your app's API key);
Statistics will start being collected as soon as the app is launched.