---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://yandex.com/dev/games/doc/en/sdk/sdk-environment.md
  - https://yandex.com/dev/games/doc/hi/sdk/sdk-environment.md
  - https://yandex.com/dev/games/doc/ko/sdk/sdk-environment.md
  - https://yandex.com/dev/games/doc/ru/sdk/sdk-environment.md
  - https://yandex.com/dev/games/doc/tr/sdk/sdk-environment.md
  - https://yandex.com/dev/games/doc/vi/sdk/sdk-environment.md
  - https://yandex.com/dev/games/doc/zh/sdk/sdk-environment.md
  - href: en/sdk/sdk-environment.md
    type: text/markdown
    title: Markdown version
  - href: ../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/games/doc/en/llms.txt

# Environment variables

<!-- source: en/_includes/script-common.md -->
<!-- source: en/_includes/script/index-js.md -->

<!-- endsource: en/_includes/script/index-js.md -->

<!-- source: en/_includes/script/requirements-js.md -->

<!-- endsource: en/_includes/script/requirements-js.md -->

<!-- source: en/_includes/script/image-modal-js.md -->

<!-- endsource: en/_includes/script/image-modal-js.md -->
<!-- endsource: en/_includes/script-common.md -->

You can get information about the environment the game is run in. To do this, use the `environment` object.

```javascript showLineNumbers
{
  [app](*key_app): {
    [id](*key_id): string;
  };
  [i18n](*key_i18n): {
    [lang](*key_lang2): string;
  };
  [payload?](*key_payload): string;
  [referrer?](*key_referrer): {
    [type](*key_type): "promo";
    [promoId](*key_promo_id): string;
    [intent?](*key_intent): string;
    [inappId?](*key_inapp_id): string;
  }
}
```

## environment object {#environment-object}

Contains game environment variables.

#|
|| **Parameter** | **Type** | **Description** ||
|| `app` | `object` | Game data. ||
|| `i18n` | `object` | Service internationalization. ||
|| `payload` | `string` | The value of the `payload` parameter from the game's address. Optional parameter. For example, in `https://yandex.ru/games/app/123?payload=test` you can return `test` as follows: `ysdk.environment.payload`. ||
|#


### app structure {#structure-app}

#|
|| **Parameter** | **Type** | **Description** ||
|| `id` | `string` | Game ID. ||
|#


### i18n structure {#structure-i18n}

#|
|| **Parameter** | **Type** | **Description** ||
|| `lang` | `string` | [Yandex Games interface language](https://yandex.com/dev/games/doc/en/concepts/languages-and-domains.md#languages) in ISO 639-1 format. For example, `"tr"` means that the game is currently running under the Yandex Games Turkish interface. Use this parameter to automatically detect the user's language in the game ([item 2.14](https://yandex.com/dev/games/doc/en/concepts/requirements.md#2-14)). ||
|#

#### Example {#i18n-example}

```javascript showLineNumbers
const ysdk = (await YaGames.init());
const lang = ysdk.environment.i18n.lang; // 'en', 'ru', ...
```

### referrer structure {#structure-referrer}

Use `ysdk.environment.referrer` to handle player transitions from promotional banners in the catalog. Benefits:

- **For the player**: after clicking a promotion, the player lands directly on the relevant screen — seeing exactly the offer they clicked on. This improves conversion and reduces early drop-off.
- **For you**: you can track the effectiveness of each promotion — how many players clicked through and how many made a purchase. To collect statistics, additionally enable [Yandex Metrica](https://yandex.com/dev/games/doc/en/concepts/yandex-metrica.md).

#### Setup {#referrer-setup}

1. In the Developer Console, add a [promotion](https://yandex.com/dev/games/doc/en/console/promo-and-discounts.md). The platform will automatically generate a deeplink for promotional banners in the catalog.

    Example link with promotion parameters:

    ```text
    https://yandex.ru/games/app/{id}?lang=ru&referrer=promo&promo_id={PROMO_ID}&promo_intent={INTENT}&inapp_id={INAPP_ID}
    ```

    #|
    || **Parameter** | **Description** | **Required** | **Source** ||
    || `referrer` | Tells the platform that the transition is from a promotion. |::{align="center"}
    ![SVG](../_images/icons/yes-button.svg) | Always `promo` ||
    || `promo_id` | Promotion ID for routing and analytics. |::{align="center"}
    ![SVG](../_images/icons/yes-button.svg) | **ID** ||
    || `promo_intent` | An arbitrary hint for in-game routing and analytics. |  | **Intent** ||
    || `inapp_id` | ID of the in-app purchase associated with the promotion in the game. |  | **In-app ID** ||
    |#

1. Add [transition handling](#referrer-example) to the game: the SDK passes deeplink parameters to the `ysdk.environment.referrer` object — use them to show the player the relevant screen.

    #|
    || **Parameter** | **Type** | **Description** | **Source** ||
    || `type` | `"promo"` | Shows the transition source. Track `type: "promo"` to collect analytics on promotions. | `referrer=promo` ||
    || `promoId` | `string` | Promotion ID from the **Promos** tab in the Console. Use it to configure an action for a specific promotion and collect analytics on it. | `promo_id` ||
    || `intent` | `string` | An arbitrary string, e.g. `open_starter_pack`. Use it to configure a default action after a promotion transition and collect analytics on it. Optional parameter. | `promo_intent` ||
    || `inappId` | `string` | [In-app purchase ID](https://yandex.com/dev/games/doc/en/console/purchases.md#add-purchases) from the **Inaps** tab in the Console. Use it to open the platform purchase dialog. Optional parameter (for discount promotions only). | `inapp_id` ||
    |#

1. Test the transitions: on the **Promos** tab, in the **Check transition** field, click **In the published version** or **In the draft**. If everything is configured correctly, you will see the promotion screen: an offer, a shop, or a specific in-app purchase.

#### Example {#referrer-example}

```javascript showLineNumbers
// 1. SDK initialization
const ysdk = await YaGames.init();

// 2. Get the referrer
const { referrer } = ysdk.environment;

// 3. Handle the promotion transition
if (referrer?.type === 'promo') {
    if (referrer.inappId) {
        showPurchaseScreen(referrer.inappId);
    } else if (referrer.intent) {
        openScreen(referrer.intent);
    }
}
```

#### Common scenarios {#referrer-scenarios}

#|
|| **Scenario** | **Target audience** | **Goal** | **Example** ||
|| Product discount | Non-paying players | First payment | `promo_id=SPRING_DISCOUNT`<br>`promo_intent=open_starter_pack`<br>`inapp_id=starter_pack_001`

→ `showPurchaseScreen()` ||
|| VIP offer or shop opening | Paying players | Increase average order value | `promo_id=VIP_PROMO`<br>`promo_intent=open_shop`

→ `openShop()` ||
|| Seasonal sale | All active players | Retention | `promo_id=SALE_SPRING_2026`

→ basic flow, banner ||
|#


---

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

Our support team can help publish finished games on Yandex Games. If you have any questions about development or testing, ask them in the [Discord channel](https://discord.com/invite/wU4p3whr4T){.external}.

{% endnote %}

If you are facing an issue or have a question regarding the use of Yandex Games SDK, please contact support:

<!-- source: en/_includes/button-chat.md -->
<a href="https://yandex.com/chat/#/user/a4fa5c06-75db-9b38-6eea-b1673785f7d5">
  <span class="button">Write to chat</span>
</a>
<!-- endsource: en/_includes/button-chat.md -->
<!-- endsource: en/_includes/sdk-support.md -->

[*key_app]: Game data.

[*key_id]: Game ID.

[*key_i18n]: Service internationalization.

[*key_lang2]: The [Yandex Games interface language](https://yandex.com/dev/games/doc/en/concepts/languages-and-domains.md#languages) in ISO 639-1 format. For example, `"tr"` means that the game is currently running under the Yandex Games Turkish interface. We recommend using this parameter to determine the user's language in the game.

[*key_payload]: The value of the `payload` parameter from the game's address.
Optional parameter.
For example, in `https://yandex.ru/games/app/123?payload=test` you can return `test` as follows: `ysdk.environment.payload`.

[*key_referrer]: Data about the transition from a promotion. Present if the game was opened via a deep link from a promotional banner. `undefined` otherwise.

[*key_type]: Transition source. Always `"promo"`.

[*key_promo_id]: Promotion ID from the **Promos** tab in the Console.

[*key_intent]: An arbitrary string, e.g. `open_starter_pack`. Optional parameter.

[*key_inapp_id]: [In-app purchase ID](https://yandex.com/dev/games/doc/en/console/purchases.md#add-purchases) from the **Inaps** tab in the Console. Optional parameter (for discount promotions only).