---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://yandex.ru/dev/direct/doc/en/example-metrika.md
  - https://yandex.ru/dev/direct/doc/ru/example-metrika.md
  - href: ru/example-metrika.md
    type: text/markdown
    title: Markdown version
  - href: llms.txt
    type: text/markdown
    title: llms.txt
sourcePath: ru/reports/example-metrika.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/dev/direct/doc/ru/llms.txt

# Пример: данные Яндекс Метрики

Пример демонстрирует получение данных Яндекс Метрики по выбранным целям и заданной модели атрибуции.

## Запрос

{% list tabs %}

- JSON

  ```text translate=no
  curl \
  -H 'Authorization: Bearer 0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f' \
  -H 'Accept-Language: en' \
  -H 'Client-Login: agrom' \
  -H 'skipReportHeader: true' \
  -H 'returnMoneyInMicros: false' \
  -d '{
    "params": {
      "SelectionCriteria": { },
      "Goals": [ "20002", "20003" ],
      "AttributionModels": [ "LSCCD" ],
      "FieldNames": [ "Date", "Clicks", "Impressions", "Conversions", "CostPerConversion", "GoalsRoi", "Revenue", "ConversionRate"], 
      "OrderBy": [{
        "Field": "Date"
      }],
      "ReportName": "Conversions",
      "ReportType": "ACCOUNT_PERFORMANCE_REPORT",
      "DateRangeType": "LAST_5_DAYS",
      "Format": "TSV",
      "IncludeVAT": "YES",
      "IncludeDiscount": "YES"
    }
  }' \
  https://api.direct.yandex.com/json/v501/reports
  ```

- XML

  ```text translate=no
  curl \
  -H 'Authorization: Bearer 0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f' \
  -H 'Accept-Language: en' \
  -H 'Client-Login: agrom' \
  -H 'skipReportHeader: true' \
  -H 'returnMoneyInMicros: false' \
  -d '<?xml version="1.0" encoding="UTF-8"?>
    <ReportDefinition xmlns="http://api.direct.yandex.com/v5/reports">
      <SelectionCriteria/>
      <Goals>20002</Goals>
      <Goals>20003</Goals>
      <AttributionModels>LSCCD</AttributionModels>
      <FieldNames>Date</FieldNames>
      <FieldNames>Clicks</FieldNames>
      <FieldNames>Impressions</FieldNames>
      <FieldNames>Conversions</FieldNames>
      <FieldNames>CostPerConversion</FieldNames>
      <FieldNames>GoalsRoi</FieldNames>
      <FieldNames>Revenue</FieldNames>
      <FieldNames>ConversionRate</FieldNames>
      <OrderBy>
        <Field>Date</Field>
      </OrderBy>
      <ReportName>Conversions</ReportName>
      <ReportType>ACCOUNT_PERFORMANCE_REPORT</ReportType>
      <DateRangeType>LAST_5_DAYS</DateRangeType>
      <Format>TSV</Format>
      <IncludeVAT>YES</IncludeVAT>
      <IncludeDiscount>YES</IncludeDiscount>
    </ReportDefinition>' \
  https://api.direct.yandex.com/v501/reports
  ```

{% endlist %}

## Ответ

```text translate=no
Date	Clicks	Impressions	Conversions_20002_LSCCD Conversions_20003_LSCCD	CostPerConversion_20002_LSCCD	CostPerConversion_20003_LSCCD	GoalsRoi_20002_LSCCD	GoalsRoi_20003_LSCCD	Revenue_20002_LSCCD	Revenue_20003_LSCCD	ConversionRate_20002_LSCCD	ConversionRate_20003_LSCCD
2018-04-15	22	3282	2	2	12.54	17.06	3.39	5.57	110	224	9.09	9.09
2018-04-16	49	7493	6	1	3.48	20.43	25.38	4.87	550	120	12.24	2.04
2018-04-17	44	5773	5	--	28.05	--	2.92	--	550	--	11.36	--
2018-04-18	51	2268	5	1	13.42	1.61	3.92	23.77	330	40	9.8	1.96
2018-04-19	33	3511	4	1	9.83	4.07	7.39	48.17	330	200	12.12	3.03
Total rows: 5
```
