Installing and configuring a tag for AJAX and Flash sites
Read these instructions if you have an AJAX or Flash site and wish to use Yandex Metrica:
- Create and install the code snippet on your site, if it is not yet installed.
- 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.
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. |
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.