---
metadata:
  - name: generator
    content: Diplodoc Platform v5.63.0
alternate:
  - en/operations/connection/create-metrica-api
  - ru/operations/connection/create-metrica-api
  - href: en/operations/connection/create-metrica-api.md
    type: text/markdown
    title: Markdown version
csp:
  - script-src:
      - https://mc.yandex.ru
    img-src:
      - https://mc.yandex.ru
    connect-src:
      - https://mc.yandex.ru
      - wss://mc.yandex.ru
    child-src:
      - 'blob:'
      - https://mc.yandex.ru
    frame-src:
      - 'blob:'
      - https://mc.yandex.ru
    frame-ancestors:
      - 'blob:'
      - https://mc.yandex.ru
canonical: en/operations/connection/create-metrica-api.html
title: How to create a Metrica connection in DataLens On-premises
description: Follow this guide to create a Metrica connection in DataLens On-premises.
vcsPath: en/operations/connection/create-metrica-api.md
---

# Creating a Metrica connection in DataLens On-premises


<!-- source: en/_includes/datalens/datalens-metrica-pro-note.md -->
{% note info %}

For advanced analysis of raw Yandex Metrica data and access to the full range of DataLens analytical functions, we recommend using data export to ClickHouse® available as part of the [Metrica Pro](https://yandex.ru/project/metrica/pro) package.

For the Metrica Pro package, real-time data streaming is available. For more information, see [this guide](https://yandex.ru/support/metrica/en/pro/data-work).

{% endnote %}
<!-- endsource: en/_includes/datalens/datalens-metrica-pro-note.md -->


To create a Yandex Metrica connection:



1. Go to the [workbook](../../workbooks-collections/index.md) page or create a new one.
1. In the top-right corner, click **Create** → **Connection**.
1. Select **Metrica** as the connection type.
1. Configure the connection as follows:
   * **OAuth token**: Specify the OAuth token to access Yandex Metrica data.
   * **App**: Specify the application ID.

   <!-- source: en/_includes/datalens/operations/datalens-get-token.md -->
   ## Getting an OAuth token {#get-oauth-token}

   You can specify an OAuth token of any Yandex account.

   To get access to a Yandex Metrica tag of a username other than your current Yandex account, follow these steps:
   1. Switch to an account that has access to Yandex Metrica.
   1. Get a token [here](https://oauth.yandex.com/authorize?response_type=token&client_id=4f802221a95340dd9417c04bc30606b5). If required, allow access to the application, then copy the token.
   1. Switch to an account that has access to DataLens On-premises.
   1. Create a new connection to Yandex Metrica and paste the obtained token from the clipboard to the **OAuth token** field.
   <!-- endsource: en/_includes/datalens/operations/datalens-get-token.md -->
   
1. Click **Create connection**.
1. Enter a name for the connection and click **Create**.

<!-- source: en/_includes/datalens/datalens-metrica-note.md -->
{% note info %}

* By default, Yandex Metrica data is exported for the last 60 days. If you add a filter by date to the chart, the Yandex Metrica filter will be reset. We recommend adding a filter by date as an offset relative to the current date.
* On the Metrica side, there is a quota of three concurrent requests per user (`user_login`).

{% endnote %}
<!-- endsource: en/_includes/datalens/datalens-metrica-note.md -->
