Installing and configuring a tag for AJAX and Flash sites

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.

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

  1. Create and install the tag code on your site, if it is not yet installed.
  2. To make sure Yandex Metrica registers important page changes, analyze the logic of your site and insert the hit function in the appropriate parts of your AJAX and Flash code so that it's called each time you believe the page has changed.
ym(XXXXXX, 'hit', [url[, options]])

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

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

If a different currency is passed, null values are sent instead of currencies and amounts.

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

For ActionScript 2 (Flash version earlier than 9.0):

getURL("javascript:ym(**XXXXXX**, 'hit', url, title, referer)");

For ActionScript 3 (Flash version 9.0 and later):

navigateToURL(new URLRequest("javascript:ym(**XXXXXX**, 'hit', url)"), "_self");

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

Chat with us

Write an email

If you were unable to independently check the tag, follow the recommendations below.

This might happen for the following reasons:

  • The tag is installed incorrectly. For example, the CMS modified the tag code. Reinstall the tag or contact the support service for your CMS.
  • Broken scripts are preventing the Yandex Metrica tag from working on the site. You can check this in the browser console.
The recommendations did not help

This means that information is being transmitted to Yandex Metrica. However, the data might not be shown in reports for any of the following reasons:

  • Data is sent to a tag with a different number.
  • The Filters tab in the tag settings has overly strict filters defined. Remove unneeded filters.
  • The Filters tab in the tag settings has the Don’t count my sessions filter enabled. This means that the tag doesn't register your own sessions. Try accessing the site with your browser in “incognito” mode.
The recommendations did not help