---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://www.yandex.com/support/metrica/en/objects/hit.md
  - https://www.yandex.com/support/metrica/es/objects/hit.md
  - https://www.yandex.com/support/metrica/pt/objects/hit.md
  - https://www.yandex.com/support/metrica/ru/objects/hit.md
  - https://www.yandex.com/support/metrica/tr/objects/hit.md
  - https://www.yandex.com/support/metrica/zh/objects/hit.md
---
> **Documentation Index:** Fetch the complete configuration index at https://www.yandex.com/support/metrica/en/llms.txt

# hit

<!-- 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 -->


Sends data about a pageview. Usually used on pages with AJAX or Flash implementation.

```javascript
ym(XXXXXXXX, 'hit', [url[, options]])
```


{% note alert %}

The [hit([url[, title[, referer[, params]]]])](https://www.yandex.com/support/metrica/en/objects/hit-url-title-referer.md) signature is outdated. It’s supported for backward compatibility, but may be deprecated at any time. We strongly discourage its use.

{% endnote %}



#|
||
**Parameter**
|
**Default value**
|
**Type**
|
**Description**
||
||
`url`[*](*Параметр)
|
:
|
String?
|
The URL of the page from which the view was made. If the URL isn't provided, the value from [`window.location.href`](https://www.yandex.com/support/metrica/en/data/visit-params-example.md#goal) is used.
||
||
`options`
|
:
|
Object
|
:
||
||
`options` fields
|
>
|
>
||
||
`options.callback`
|
:
|
Function
|
The callback function to call after sending pageview data
||
||
`options.ctx`
|
:
|
Object
|
Context accessed by the `this` keyword in the callback function
||
||
`options.params`
|
:
|
Object
|
Session parameters
||
||
`options.referer`
|
:
|
String
|
The URL that the user loaded the current page contents from
||
||
`options.title`
|
`document.title`
|
String
|
Title of the current page
||
||
Fields for the `options.params` object:
|
>
|
>
||
||
`order_price`
|
:
|
Double
|
[Revenue by goal](#price). You can set the cost in a currency or 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 -->
||
|#
 
<sup >*</sup> Required parameter.

With the `url` and `options.referer` parameters, you can use URL paths without a schema (protocol) and host.

In this case, if a path starts with a `/`, the URL is assumed to be set from the root of the host.

```javascript
ym(XXXXXXXX, 'hit', '/contacts');
```

Otherwise, the path is assumed to be relative to the current page.

```javascript
ym(XXXXXXXX, 'hit', 'contacts', {params:{'param': 'value'}});
```

> # Example
> 
> ```javascript
> ym(XXXXXXXX, 'init', {});
> //...
> ym(XXXXXXXX, 'hit', '#contacts',{params:{
>     'Page title': 'Contact information',
>     'another_param': 'another_value'
> }});
> ```

## Revenue by goal {#price}

If pageview is one of the goals configured on your website, you can transmit the revenue in the method parameters. [Details about revenue by goal](https://www.yandex.com/support/metrica/en/general/price-goal.md)

Example:

```javascript
var goalParams =
{
   order_price: 1000.35,
   currency: "RUB"
};
ym(XXXXXXXX, 'hit', '/contacts', {params: goalParams})
```

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

{% endcut %}

</div>

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

<!-- endsource: en/_includes/styles/cut-button.md -->
<!-- endsource: en/_includes/buttons/support-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 -->

[*Параметр]: <sup >*</sup> Required parameter.