---
metadata:
  - name: generator
    content: Diplodoc Platform v5.55.3
alternate:
  - https://www.yandex.com/support/metrica/en/objects/method-sprav.md
  - https://www.yandex.com/support/metrica/es/objects/method-sprav.md
  - https://www.yandex.com/support/metrica/pt/objects/method-sprav.md
  - https://www.yandex.com/support/metrica/ru/objects/method-sprav.md
  - https://www.yandex.com/support/metrica/tr/objects/method-sprav.md
  - https://www.yandex.com/support/metrica/zh/objects/method-sprav.md
  - href: en/objects/method-sprav.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://www.yandex.com/support/metrica/en/llms.txt


# Reference of methods in the previous version

In Yandex Metrica, the code snippet for tags and [the JavaScript API methods](https://www.yandex.com/support/metrica/en/objects/method-reference.md) have been updated. The previous version of the methods is shown below.


{% cut "addFileExtension" %}


Tracks downloads of files with the specified extensions.

```javascript
addFileExtension(extensions)
```

The `extensions` parameter is the same as the parameter in the [new version of the method](https://www.yandex.com/support/metrica/en/objects/addfileextension.md).


{% endcut %}




{% cut "extLink" %}


Sending information about external link traffic.

```javascript
extLink(url[, options])
```

The `url` and `options` parameters are the same as the parameters in the [new version of the method](https://www.yandex.com/support/metrica/en/objects/extlink.md).


{% endcut %}

{% cut "file" %}


Sends information about file downloads.

```javascript
file(url[, options])
```

The `url` and `options` parameters are the same as the parameters in the [new version of the method](https://www.yandex.com/support/metrica/en/objects/file.md).


{% endcut %}

{% cut "getClientID" %}


Get the site user ID assigned by Yandex Metrica.

```javascript
yaCounterXXXXXXXX.getClientID()
```


{% endcut %}

{% cut "hit" %}


Sends data about a pageview.

```javascript
hit(url[, options])
```

Example:

```javascript
var yaCounterXXXXXXXX = new Ya.Metrika({id: XXXXXXXX});
//...
yaCounterXXXXXXXX.hit('#!contacts', {
    title: 'Contact',
    referer: 'http://example.com/#!main'
});
```

The `url` and `options` parameters are the same as the parameters in the [new version of the method](https://www.yandex.com/support/metrica/en/objects/hit.md).


{% endcut %}

{% cut "notBounce" %}


Sends information about non-bounces.

```javascript
notBounce([options])
```

The `options` parameter is the same as the parameter in the [new version of the method](https://www.yandex.com/support/metrica/en/objects/notbounce.md).


{% endcut %}

{% cut "params" %}


Transmitting custom [session parameters](https://www.yandex.com/support/metrica/en/data/visit-params-data.md).

```javascript
params(parameters)
```

Examples of transmitting session parameters:


{% cut "User status" %}


```javascript
var yaParams = {
    x: 10,
    y: "unauthorized user"
}

var yaCounterXXXXXXXX = new Ya.Metrika({id: XXXXXXXX, params: window.yaParams||{}});
```


{% endcut %}

{% cut "A/B testing" %}


Let’s say we need to conduct an experiment to determine how the color of the **Buy** button affects the conversion rate for a “View basket” goal.

If the user is shown a red button, we use the following parameter:
```javascript
var yaParams = {ab_test: "red button"};
```

If the user is shown a green button, we use the following parameter:

```javascript
var yaParams = {ab_test: "green button"};
```

This parameter is transmitted in any convenient way. For example, it can be passed when initializing the tag on product pages or using the reachGoal method that is called when the **Buy** button is clicked.


{% endcut %}

{% cut "Transmitting a hierarchical data structure" %}


```javascript
var yaParams = {
    "level1":{"level2":["level3_1","level3_2"]}}
...
```


{% endcut %}


The `parameters` parameter is the same as the parameter in the [new version of the method](https://www.yandex.com/support/metrica/en/objects/params-method.md).


{% endcut %}

{% cut "reachGoal" %}


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

```javascript
reachGoal(target[, params[, callback[, ctx]]])
```

Examples of setting goals:


{% cut "Forms" %}


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


{% endcut %}

{% cut "For a button:" %}


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


{% endcut %}

{% cut "Links:" %}


```javascript
...
<a href="/price.zip" onclick="yaCounterXXXXXXXX.reachGoal('TARGET_NAME'); return true;">Price list</a>
...
```


{% endcut %}

{% cut "For a link with transmission of user parameters:" %}


```javascript
...

<a href="/price.zip" onclick="yaCounterXXXXXXXX.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:

**Solution 1**

 
:   ```javascript
    
    ```

**Solution 2 (for jQuery)**

 
:   ```javascript
    
    ```


{% endcut %}

{% cut "Setting the value of a goal for a form" %}


```javascript
...

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


{% endcut %}


The `target`, `params`, `callback`, and `ctx` parameters are the same as in the [new version of the method](https://www.yandex.com/support/metrica/en/objects/reachgoal.md).


{% endcut %}

{% cut "setUserID" %}


Transmitting the site user ID set by the site owner.

```javascript
yaCounterXXXXXXXX.setUserID("12345")
```


{% endcut %}

{% cut "userParams" %}


Transmitting custom parameters of site users.

```javascript
userParams(parameters)
```

The `parameters` parameter is the same as the parameter in the [new version of the method](https://www.yandex.com/support/metrica/en/objects/user-params.md).


{% endcut %}

<!-- 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/reports/support-button.md -->
<div class="cut-button">

{% cut "Write an email" %}

<!-- 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/1705/?&iframe=1&lang=en">
  </iframe>
</div>

{% endcut %}

</div>



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

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

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

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