[Yandex Cloud documentation](../../../index.md) > [Yandex DataLens](../../index.md) > Connections > Files and services > Creating a Yandex Metrica API connection

# Creating a Metrica connection in Yandex DataLens


{% 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 %}


To create a Yandex Metrica connection:


1. Open the [connection creation page](https://datalens.ru/connections/new).
1. Under **Files and services**, select the **Metrica** connection.
1. Configure the connection as follows:

   * **OAuth token**: Click **Get token** or enter the [OAuth token](#get-oauth-token) manually to access the Yandex Metrica data.
   * **Counter**: Specify one or multiple tags to connect to.
    
     {% note info %}
     
     If you want to get access for a username other than your current Yandex account or there is no relevant tag in the list, see [Getting an OAuth token](#get-oauth-token).
     
     You cannot connect multiple tag from different accounts at the same time.
     
     {% endnote %}

   * **Accuracy**: Set the data accuracy (sampling rate). You can change the accuracy after you create the connection.
   * Leave the **Automatically create dashboard, charts, and dataset on top of connection** option enabled if you need a folder with a standard set of datasets and charts and a ready-made dashboard.

1. Click **Create connection**.


1. Select the [workbook](../../workbooks-collections/index.md) to save your connection to or create a new one. If using legacy folder navigation, select a folder to save the connection to. Click **Create**.


1. Enter a name for the connection and click **Create**.

{% 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 %}


Connections to the Yandex Metrica API do not support [public access](../../concepts/datalens-public.md) to objects created based on it. To share a dashboard or chart created based on this connection, use one of the following methods:

* [Add](../../security/add-new-user.md) a user to your organization or cloud and grant them access to a dashboard or chart.
* [Export](../../qa/connections.md#uploading-data-logs-api) data to a [Managed Service for ClickHouse®](../../../managed-clickhouse/index.md) cluster and use a connection to the ClickHouse® database as a source. To learn more about the Managed Service for ClickHouse® pricing plans, see [Pricing](../../../managed-clickhouse/pricing.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 Yandex DataLens.
1. Create a new connection to Yandex Metrica and paste the obtained token from the clipboard to the **OAuth token** field.

_ClickHouse® is a registered trademark of [ClickHouse, Inc](https://clickhouse.com)._