---
metadata:
  - name: generator
    content: Diplodoc Platform v5.63.1
alternate:
  - https://www.yandex.ru/support/metrica/en/general/goal-js-event.md
  - https://www.yandex.ru/support/metrica/es/general/goal-js-event.md
  - https://www.yandex.ru/support/metrica/pt/general/goal-js-event.md
  - https://www.yandex.ru/support/metrica/ru/general/goal-js-event.md
  - https://www.yandex.ru/support/metrica/tr/general/goal-js-event.md
  - href: https://www.yandex.ru/support/metrica/en/general/goal-js-event.md
    type: text/markdown
    title: Markdown version
  - href: https://www.yandex.ru/support/metrica/en/llms.txt?revision=r21566194
    rel: describedby
title: Goal via “JavaScript event”
description: This type of goal lets you track events on a site (such as button clicks and form submissions) that occur without the page URL changing.
keywords: configuring Metrica events
---
> **Documentation Index:** Fetch the complete configuration index at https://www.yandex.ru/support/metrica/en/llms.txt?revision=r21566194


# Conversion

Use the Conversion goal to track both online and offline events.

This type of goal lets you track various events on your site — from simple actions (button clicks, form submissions) to complex programmed scenarios with multiple conditions. It also supports transmitting data about offline conversions that occurred outside your site (for example, order payments). With this goal type, you can track virtually any user actions.

To pass data about online events, use the [reachGoal](https://www.yandex.ru/support/metrica/en/objects/reachgoal.md) method. For offline events, follow the instructions for [transmitting offline data](https://www.yandex.ru/support/metrica/en/data/offline-conversion-data.md).

{% note tip %}

If you're not comfortable with coding, use:
- The [Form submission](https://www.yandex.ru/support/metrica/en/simple-goal/form.md) goal.
- The [Click on button](https://www.yandex.ru/support/metrica/en/simple-goal/click.md) goal.
- Pre-built [integrations with Yandex Metrica](https://www.yandex.ru/support/metrica/en/marketplace.md).
- Other goals from the **Conversion actions** and **Engagement** sections in the goal builder.

{% endnote %}

## How to create a target event {#create-goal}

{% note info %}

Goal identifiers for **matches** and **contains** [conditions](#conditions) mustn't contain the following characters: `/`, `\`, `&`, `#`, `?`, `=`, and `"`. If you need to add to an ID the `+` sign, replace it with `%2B`.

{% endnote %}

1. In Yandex Metrica, use the left menu to go to the **Goals** page and click **Add goal**.
1. Select the **Conversion** goal type.
1. In the **Name** field, enter a goal name.
1. Specify a [condition](#conditions) and goal identifier.
1. Configure data transmission to Yandex Metrica based on the data transfer method (online or offline).

    {% list tabs %}

    - Online

      To transmit a target event from your site to Yandex Metrica, add code with the [reachGoal](https://www.yandex.ru/support/metrica/en/objects/reachgoal.md) method to the page.

      Examples:

      {% cut "Clicking a button" %}

      ```javascript
      <form action="">
      ...
      <input type="button" onclick="ym(XXXXXXXX, 'reachGoal', 'TARGET_NAME'); return true;" value="Order" />
      </form>
      ```

      - `XXXXXXXX` — The ID of your tag.
      - `TARGET_NAME` — Goal ID.


      {% endcut %}

      {% cut "Filling in a form" %}

      ```javascript
      ...
      <form action="" method="get" onsubmit="ym(XXXXXXXX, 'reachGoal', 'TARGET_NAME'); return true;">
      ...
      </form>
      ...
      ```

      - `XXXXXXXX` — The ID of your tag.
      - `TARGET_NAME` — Goal ID.

      {% endcut %}

      {% cut "Sending revenue by goal" %}

      ```javascript
      ...
      <form action="">
      ...
      <input type="button" onclick="ym(XXXXXXXX, 'reachGoal', 'TARGET_NAME', {order_price: '1000.35', currency: 'RUB'}); return true;" value="Order"/>
      </form>
      ...
      ```

      - `XXXXXXXX` — The ID of your tag.
      - `TARGET_NAME` — Goal ID.
      - `order_price` — Revenue by goal. You can specify revenue in a currency or in conventional units.
      - `currency` — Currency of the revenue by goal. Yandex Metrica understands three-letter [ISO 4217 currency codes](https://www.six-group.com/en/products-services/financial-information/data-standards.html#scrollTo=currency-codes).

      {% endcut %}

    - Offline

      To send an offline target event, use:
      - The [Yandex Metrica web interface](https://www.yandex.ru/support/metrica/en/data/offline-conversion-data.md#upload-file).
      - The [Yandex Metrica API](https://yandex.ru/dev/metrika/doc/api2/practice/offline-conv-docpage/).
      - The Albato automation service ([setup instructions](https://albato.ru/yandex-offline-conversion)).


      To learn more, see [Transmitting and processing data](https://www.yandex.ru/support/metrica/en/data/offline-conversion-data.md).

    {% endlist %}
    
1. Click **Add goal**. The new goal will appear in the list. Yandex Metrica will start collecting statistics within a few minutes.
1. [Check](https://www.yandex.ru/support/metrica/en/general/check-goal.md) whether the goal works correctly.

![](../_assets/goal-js-event.png =750x){.border-yes}

### Conditions for tracking a goal {#conditions}

There are several types of conditions available when creating a goal. Conditions are combined with the OR operator, so the goal is considered completed if at least one of the set conditions is met.

#|
||
**Criterion**
|
**Description**
||
||
**matches**
|
A full goal identifier is specified.
||
||
**contains**
|
A part of the ID is specified. Use this option if there are multiple goals and they can be combined with a single condition. Specify as much of the ID as possible so that only the desired goals are achieved.

{% cut "Example" %}

If the condition is `button`, the goal will be completed for the `goal-button`, `button-goal`, and `goal-buy-button` IDs.

{% endcut %}
||
||
**regular expression**
|
This is used for tracking goal identifiers that match a [custom template](https://www.yandex.ru/support/metrica/en/general/regexp.md).

When setting up the condition, the regular expression must only contain the identifier value (without any domain or website protocol).

{% cut "Example" %}

{% include [create-goal-code-exm-js](../_includes/general/goal-js-event/id-create-goal/code-exm-js.md) %}

{% endcut %}
||
|#


## Restrictions {#general}

- <!-- source: en/_includes/general/goal-page-visit/id-general/1.md -->
  A maximum of 200 goals can be set for each tag.
  <!-- endsource: en/_includes/general/goal-page-visit/id-general/1.md -->
    
- <!-- source: en/_includes/general/goal-page-visit/id-general/2.md -->
  The service registers a user reaching the same goal on the same counter no more than once per second.
  <!-- endsource: en/_includes/general/goal-page-visit/id-general/2.md -->
    
- <!-- source: en/_includes/general/goal-page-visit/id-general/3.md -->
  During a single user session, the service can register up to 1000 offline conversions and 400 online conversions created for the tag.
  <!-- endsource: en/_includes/general/goal-page-visit/id-general/3.md -->
    
- <!-- source: en/_includes/general/goal-page-visit/id-general/4.md -->
  If you edit the tag or a goal, all the previously collected information does not change. 
  <!-- endsource: en/_includes/general/goal-page-visit/id-general/4.md -->
    
- <!-- source: en/_includes/general/goal-page-visit/id-general/5.md -->
  If you delete a goal, information collected for it is no longer available in reports.
  <!-- endsource: en/_includes/general/goal-page-visit/id-general/5.md -->
    

### Learn more

- [How to create a report for a goal](https://www.yandex.ru/support/metrica/en/reports/goals.md)
- [How to properly set up reachGoal in forms](https://yandex.ru/blog/metrika-club/kak-pravilno-nastroit-reachgoal-v-formakh)

<!-- source: en/_includes/buttons/chat-button.md -->
[Chat with us](https://yandex.ru/chat/#/user/036e6a02-3620-9cdc-4c5e-a34667a7379e?utm_source=spravka){.button}

<!-- source: en/_includes/styles/href-to-button.md -->

<!-- endsource: en/_includes/styles/href-to-button.md -->
<!-- endsource: en/_includes/buttons/chat-button.md -->

<!-- source: en/_includes/reports/texing-button.md -->
<div class="cut-button">

{% cut "Write an email" %}

{% list tabs radio %}

- No data for a particular source

  Goals in Yandex Metrica work the same way for any sources. Perhaps there aren’t any users who have completed the goal from this source yet.

  {% cut "The recommendations did not help" %}

  <!-- source: en/_includes/popup/id-popup/wrong-sup.md -->
  Please note: Our support team will never initiate a call to you. Do not follow any instructions of people who call you and introduce themselves as the Yandex Metrica support team.
  <!-- endsource: en/_includes/popup/id-popup/wrong-sup.md -->

  <div style="padding: 15px;
       margin: 10px 0;
       background: #FFFFFF;
       border-radius: 10px;
       border: 1px solid var(--g-color-line-generic);">
    <iframe style="background: #FFFFFF;"
          height="700"
          width="100%"
          frameborder="0"
          src="https://forms.yandex.ru/surveys/1706/?&theme=Net dannyh po opredelennomu istochniku&iframe=1&lang=en">
    </iframe>
  </div> 

  {% endcut %}

- Data for a goal doesn’t match real data

  This might happen for the following reasons:
  - The goal condition in Yandex Metrica doesn't cover all the possibilities. For example, the goal is set as going to the order confirmation page, but the site also allows instant checkout without visiting this page.
  - The site user has a browser plugin that blocks the Yandex Metrica tag, so this user isn’t counted.
  - The user has an antivirus system with strict privacy settings.
  - The user has a slow internet connection, so the Yandex Metrica tag didn’t load on the target page.

  {% cut "The recommendations did not help" %}

  <!-- source: en/_includes/popup/id-popup/wrong-sup.md -->
  Please note: Our support team will never initiate a call to you. Do not follow any instructions of people who call you and introduce themselves as the Yandex Metrica support team.
  <!-- endsource: en/_includes/popup/id-popup/wrong-sup.md -->

  <div style="padding: 15px;
       margin: 10px 0;
       background: #FFFFFF;
       border-radius: 10px;
       border: 1px solid var(--g-color-line-generic);">
    <iframe style="background: #FFFFFF;"
          height="700"
          width="100%"
          frameborder="0"
          src="https://forms.yandex.ru/surveys/1706/?&theme=Dannye po celi otlichayutsya ot realnyh dannyh&iframe=1&lang=en">
    </iframe>
  </div> 

  {% endcut %}

- Goal doesn’t work
  
  <div style="padding: 15px;
       margin: 10px 0;
       background: #FFFFFF;
       border-radius: 10px;
       border: 1px solid var(--g-color-line-generic);">
    <iframe style="background: #FFFFFF;"
          height="700"
          width="100%"
          frameborder="0"
          src="https://forms.yandex.ru/surveys/10018080.618d9fdb2524ebc4674fd9e2a54cd71036f465a9/?&theme=Cel ne rabotaet&iframe=1&lang=en">
    </iframe>
  </div> 

{% endlist %}  

{% endcut %}

</div>

<!-- source: en/_includes/styles/cut-button.md -->

<!-- endsource: en/_includes/styles/cut-button.md -->
<!-- endsource: en/_includes/reports/texing-button.md -->


<!-- source: en/_includes/footer-links.md -->
- - -

<div class="borderless-table">

#|
||
Useful links

- [Demo tag](https://metrika.yandex.com/r/dashboard?)
- [Add a tag](https://metrika.yandex.com/add/)
- [Free tag setup](https://yandex.com/promo/freeservice/metrica?utm_source=help_metrica_ru&utm_medium=cpc&utm_campaign=1)
- [Yandex Metrica API](https://tech.yandex.com/metrika/)
- [Suggest your idea](https://yandex.com/support/metrica/troubleshooting/idea.html)
- [Discuss in Telegram](https://t.me/yandexmetrika)
|
Online training

- [Get a Yandex Metrica certificate](https://yandex.ru/adv/expert/exam/metrika/?utm_source=metrika_help&utm_medium=web&utm_campaign=static&utm_content=useful_links)


- [Take a training course](https://yandex.ru/adv/edu/online/metrika?utm_source=metrika_help&utm_medium=web&utm_campaign=static&utm_content=useful_links)

||
|#

</div>

<!-- source: en/_includes/styles/table-style.md -->

<!-- endsource: en/_includes/styles/table-style.md -->
<!-- endsource: en/_includes/footer-links.md -->

<!-- source: en/_includes/styles/href-to-button.md -->

<!-- endsource: en/_includes/styles/href-to-button.md -->

<!-- source: en/_includes/styles/cut-button.md -->

<!-- endsource: en/_includes/styles/cut-button.md -->

{% included (../_includes/general/goal-js-event/id-create-goal/code-exm-js.md) %}

If you want to track clicking a particular button with the ID that contains `button` or `buy`, you can specify the following condition: `button|buy`.


{% endincluded %}