Metrica

hit

Tip. Working with the JavaScript API requires knowledge of HTML and JavaScript. If you don't have these skills, contact your website developer or webmaster.

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

hit(url[, options])
Attention! The hit(url, [title[, referer[, params]]]) signature is outdated. Supported for backward compatibility, but may be deprecated at any time. We strongly discourage its use.

Parameter

Default value

Type

Description

url *
[no-highlight[

* Required parameter.

]no-highlight]

String

Current page URL.

options

Object

Field for the options object
options.callback

Function

The callback function to call after sending pageview data

options.ctx

Object

The 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

* Required parameter.

The url and options.referer parameters allow using URL paths without the schema (protocol) and host.

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

yaCounterXXXXXX.hit('/contacts');

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

yaCounterXXXXXX.hit('contacts', {referer: 'index.html?page=main'});

Example

var yaCounterXXXXXX = new Ya.Metrika({id: XXXXXX});
//...
yaCounterXXXXXX.hit('#!contacts', {
    title: 'Contacts',
    referer: 'http://site.ru/#!main'
});