Analytics

YandexNet.Metrika

.NET SDK for the Yandex Metrika API

YandexNet.Metrika version on NuGetYandexNet.Metrika downloads on NuGetMITC#
netstandard2.0net8.0net10.0

Features

  • Goals: list, create, update and delete
  • Offline-conversion upload with server-side revenue attribution
  • Reading reports
  • OAuth 2.0 helpers or bring-your-own token
  • Stateless, only depends on System.Text.Json

Installation

bash
dotnet add package YandexNet.Metrika

Quick start

csharp
using YandexNet.Metrika;

using var http = new HttpClient();

// Bring your own token — no OAuth round-trip needed.
var metrika = new YandexMetrikaClient(http, new YandexMetrikaClientOptions
{
    AccessToken = accessToken,
});

var goals = await metrika.ListGoalsAsync(counterId);

var created = await metrika.CreateGoalAsync(counterId, new MetrikaGoal
{
    Name = "app_open",
    Type = "action",
    Conditions = new[] { new MetrikaGoalCondition { Type = "exact", Url = "app_open" } },
});

Key methods

ListGoalsAsyncList a counter’s goals
CreateGoalAsyncCreate a goal
UploadOfflineConversionsAsyncUpload offline conversions
BuildAuthorizeUrlBuild the OAuth authorize URL
ExchangeCodeAsyncExchange the code for tokens
READMEgithub.com/ai-iskuzhin/YandexNet.Metrika
Loading README from the repository…