hit
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.
Sends data about a pageview. Usually used on pages with AJAX or Flash implementation.
ym(XXXXXX, 'hit', [url[, options]])
Alert
The hit([url[, title[, referer[, params]]]]) signature is outdated. It’s supported for backward compatibility, but may be deprecated at any time. We strongly discourage its use.
Parameter |
Default value |
Type |
Description |
|
: |
String? |
The URL of the page from which the view was made. If the URL isn't provided, the value from |
|
: |
Object |
: |
|
|||
|
: |
Function |
The callback function to call after sending pageview data |
|
: |
Object |
Context accessed by the |
|
: |
Object |
Session parameters |
|
: |
String |
The URL that the user loaded the current page contents from |
|
|
String |
Title of the current page |
Fields for the |
|||
|
: |
Double |
Revenue by goal. You can set the cost in a currency or conventional units. |
|
: |
String |
Use this field if you want to pass the goal cost in currency. Yandex Metrica recognizes a three-letter ISO 4217 currency code. If a different currency is passed, null values are sent instead of currencies and amounts. |
* 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.
ym(XXXXXX, 'hit', '/contacts');
Otherwise, the path is assumed to be relative to the current page.
ym(XXXXXX, 'hit', 'contacts', {params:{'param': 'value'}});
Example
ym(XXXXXX, 'init', {}); //... ym(XXXXXX, 'hit', '#contacts',{params:{ 'Page title': 'Contact information', 'another_param': 'another_value' }});
Revenue by goal
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
Example:
var goalParams =
{
order_price: 1000.35,
currency: "RUB"
};
ym(XXXXXX, 'hit', '/contacts', {params: goalParams})
Useful links |
Online training |
* Required parameter.