Metrica

Yandex.Metrica for AJAX and Flash websites

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.

Read these instructions if you have an AJAX or Flash site and wish to use Yandex.Metrica:

  1. Create and install the counter code on your site, if it is not yet installed.
  2. In order for Yandex.Metrica to register important changes to a page, analyze the logic of your site and insert a hit function in the appropriate parts of AJAX and Flash code so it’s triggered each time you believe the page has changed.
hit(url[, options])

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

yaCounterXXXXXX.hit('http://example.com#contacts', {title: 'Contacts', referer: 'http://example.com/#main'});

For ActionScript 2 (Flash version earlier than 9.0):

getURL("javascript:yaCounterXXXXXX.hit(url, title, referer)");

For ActionScript 3 (Flash version 9.0 and later):

navigateToURL(new URLRequest("javascript:yaCounterXXXXXX.hit(url)"), "_self");

If you want to register a goal completion for a specific action on the page, use the reachGoal function.