---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://yandex.com/support/metrica/en/objects/reachgoal.md
  - https://yandex.com/support/metrica/es/objects/reachgoal.md
  - https://yandex.com/support/metrica/pt/objects/reachgoal.md
  - https://yandex.com/support/metrica/ru/objects/reachgoal.md
  - https://yandex.com/support/metrica/tr/objects/reachgoal.md
  - https://yandex.com/support/metrica/zh/objects/reachgoal.md
  - href: en/objects/reachgoal.md
    type: text/markdown
    title: Markdown version
  - href: ../llms.txt
    type: text/markdown
    title: llms.txt
title: reachGoal
description: Transmits information about a completed goal.
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/support/metrica/en/llms.txt


# reachGoal

<!-- source: en/_includes/code/counter-initialize/id-counter-initialize/rest-js.md -->
{% note warning %}

Working with the JavaScript API requires knowledge of HTML and JavaScript. If you don’t know these languages, contact your website developer or webmaster.

{% endnote %}
<!-- endsource: en/_includes/code/counter-initialize/id-counter-initialize/rest-js.md -->


Transmits information about a completed [goal](https://yandex.com/support/metrica/en/general/goals.md).

```javascript
ym(XXXXXXXX, 'reachGoal', target[, params[, callback[, ctx]]]);
```


#|
||
**Parameter**
|
**Default value**
|
**Type**
|
**Description**
||
||
`target`[*](*parametr)
|
—
|
String
|
ID of the goal. Set on the tag editing page when [creating or changing](https://yandex.com/support/metrica/en/general/goal-js-event.md) a goal of the “JavaScript event” type.
||
||
`params`
|
—
|
Object
|
[Session parameters](https://yandex.com/support/metrica/en/data/visit-params-data.md)
||
||
`callback`
|
—
|
Function
|
The callback function to call after sending pageview data
||
||
`ctx`
|
—
|
Object
|
Context accessed by the `this` keyword in the callback function
||
||
Fields for the `params` object:
|
>
|
>
|
>
||
||
`order_price or price`
|
—
|
Double
|
[Goal cost](https://yandex.com/support/metrica/en/general/goal-js-event.md). You can specify revenue in a currency or in conventional units.
||
||
`currency`
|
—
|
String
|
Use this field if you want to pass the goal cost in currency. Yandex Metrica recognizes a three-letter [ISO 4217 currency code](https://www.six-group.com/en/products-services/financial-information/data-standards.html#scrollTo=currency-codes).

<!-- source: en/_includes/ecommerce/data/id-about/currency-note.md -->
If a different currency is passed, null values are sent instead of currencies and amounts.
<!-- endsource: en/_includes/ecommerce/data/id-about/currency-note.md -->
||
|#


If you want to track the same action in multiple locations, simply [create](https://yandex.com/support/metrica/en/general/goal-js-event.md) one [JavaScript event](https://yandex.com/support/metrica/en/general/goal-js-event.md) goal and call the `reachGoal` method with the goal ID each time the goal is completed.

If you have a number of different events, create a separate goal for each event and track them separately. In this case, goals must have different IDs.


{% note alert %}

When setting the goal ID, don't use the following symbols: / \ & # ? = ". If you want to add a plus sign to the ID, enter `%2B` in place of the + character.

{% endnote %}


## Examples {#reach_goal_examples}

> Options for embedding goals in the source code of your site:
> 
> 
> {% cut "Forms" %}
> 
> 
> ```javascript
> ...
> <form action="" method="get" onsubmit="ym(XXXXXXXX, 'reachGoal', 'TARGET_NAME'); return true;">
>     ...
> </form>
> ...
> ```
> 
> 
> {% endcut %}
> 
> {% cut "For a button:" %}
> 
> 
> ```javascript
> ...
> <form action="">
>     ...
>     <input type="button" onclick="ym(XXXXXXXX, 'reachGoal', 'TARGET_NAME'); return true;" value="Order" />
> </form>
> ...
> ```
> 
> 
> {% endcut %}
> 
> {% cut "Links:" %}
> 
> 
> ```javascript
> ...
> <a href="/price.zip" onclick="ym(XXXXXXXX, 'reachGoal', 'TARGET_NAME'); return true;">Price list</a>
> ...
> ```
> 
> 
> {% endcut %}
> 
> {% cut "For a link with transmission of user parameters:" %}
> 
> 
> ```javascript
> ...
> 
> <a href="/price.zip" onclick="ym(XXXXXXXX, 'reachGoal', 'TARGET_NAME', goalParams, goalCallback); return true;">Price list</a>
> ...
> ```
> 
> 
> {% endcut %}
> 
> {% cut "Goal completion on page loading" %}
> 
> 
> If you are using an **asynchronous** code snippet and the goal is called using the `script` element, embed the following code in any section of the page:
> 
> 
> {% list tabs %}
> 
> - General solution
> 
>   
>   ```javascript
>   
>   ```
>   
> 
> - Solution for jQuery
> 
>   
>   ```javascript
>   
>   ```
> 
> {% endlist %}
> 
> 
> 
> {% endcut %}
> 
> {% cut "Setting revenue by goal on a form" %}
> 
> 
> ```javascript
> ...
> <form action="">
>     ...
>     <input type="button" onclick="ym(XXXXXXXX, 'reachGoal', 'TARGET_NAME', {order_price: '1000.35', currency: 'RUB'}); return true;" value="Order"/>
> </form>
> ...
> ```
> 
> {% cut "How to send revenue data using an attribute selector" %}
> 
> 
> To transfer revenue as `order_price` from all pages of the site where it is set by an attribute selector (for example, `class` or `id`), pass the selector name along with the revenue data to Yandex Metrica.
> 
> 1. Find the fragment in your site code where a selector of this type is set. Example:
>     ```html
>     <div class="ORDER">Order amount: <div class="PRICE">110</div> RUB</div>
>     ```
>     
> 1. Add the selector name to the code of the element that will send the revenue by goal to Yandex Metrica. Example:
>     ```javascript
>     <input type="button" onclick="ym(XXXXXXXX, 'reachGoal', 'BUY', {order_price: document.querySelector('.PRICE')?.textContent}); return true;" value="Order" />
>     ```
>     
> 
> 
> {% endcut %}
> 
> 
> {% endcut %}
> 
> {% cut "Passing revenue by goal dynamically using JQuery" %}
> 
> 
> ```javascript
> 
> <form id="cart" action="/submit_order.php" method="post">
>     <div class="item">
>       <div class="name">Dakimakura with JoJo</div>
>       <div class="price">RUB 3000.5</div>
>       <input class="price-input hidden" value="3000.5" />
>     </div>
>     ...
> </form>
> ```
> 
> 
> {% endcut %}
> 
> 
> - `XXXXXXXX` — Counter number.
> - `TARGET_NAME` — Goal ID.


<!-- source: en/_includes/buttons/chat-button.md -->
[Chat with us](https://yandex.com/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/objects/mail-button.md -->
<div class="cut-button">

{% cut "Write an email" %}

Select a question to find a solution.

{% 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.com/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.com/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.com/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/objects/mail-button.md -->

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

<div class="borderless-table">

#|
||
Useful links

- [Demo tag](https://metrica.yandex.com/r/dashboard?)
- [Add a tag](https://metrica.yandex.com/add/)
- [Free tag setup](https://yandex.com/promo/freeservice/metrica?utm_source=help_metrica_en&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.com/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 -->

[*parametr]: Required parameter.