hit
Sends data about a pageview. Usually used on pages with AJAX or Flash.
ym(XXXXXX, 'hit', url[, options])
Parameter | Default value | Type | Description |
---|---|---|---|
url * | — | string | Current page URL |
options | — | Object | — |
options fields | |||
options.callback | — | Function | The callback function to call after sending pageview data |
options.ctx | — | Object | Context accessed by the |
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 |
options.params fields: | |||
order_price | — | Double | Revenue by goal. You can set the cost in currency or Yandex units. |
currency | — | string | Use this field if you want to pass the goal cost in currency. Yandex Metrica recognizes three-letter ISO 4217 currency codes If a different currency is passed, null values will be sent instead of currencies and amounts. |
Parameter | Default value | Type | Description |
---|---|---|---|
url * | — | string | Current page URL |
options | — | Object | — |
options fields | |||
options.callback | — | Function | The callback function to call after sending pageview data |
options.ctx | — | Object | Context accessed by the |
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 |
options.params fields: | |||
order_price | — | Double | Revenue by goal. You can set the cost in currency or Yandex units. |
currency | — | string | Use this field if you want to pass the goal cost in currency. Yandex Metrica recognizes three-letter ISO 4217 currency codes If a different currency is passed, null values will be sent instead of currencies and amounts. |
* Required parameter.
The url
and options.referer
parameters let you use URL paths without a schema (protocol) or 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:{referer: 'index.html?page=main'}});
Example
ym(XXXXXX, 'init', {});
//...
ym(XXXXXX, 'hit', '#contacts', {params:{
title: 'Contact information',
referer: 'http://example.com/#main'
}});
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})