---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://www.yandex.com/support/metrica/en/code/ajax-flash.md
  - https://www.yandex.com/support/metrica/es/code/ajax-flash.md
  - https://www.yandex.com/support/metrica/pt/code/ajax-flash.md
  - https://www.yandex.com/support/metrica/ru/code/ajax-flash.md
  - https://www.yandex.com/support/metrica/tr/code/ajax-flash.md
  - https://www.yandex.com/support/metrica/zh/code/ajax-flash.md
---
> **Documentation Index:** Fetch the complete configuration index at https://www.yandex.com/support/metrica/zh/llms.txt

# 为 AJAX 和 Flash 网站安装和配置计数器

<!-- source: zh/_includes/code/counter-initialize/id-counter-initialize/rest-js.md -->
{% note warning %}

使用 JavaScript API 需要了解 HTML 和 JavaScript。 如果您不了解这些语言，请联系您的网站开发人员或站长。

{% endnote %}
<!-- endsource: zh/_includes/code/counter-initialize/id-counter-initialize/rest-js.md -->


如果您有 AJAX 或 Flash 网站并希望使用 Yandex Metrica，请阅读以下说明：

1. [在您的网站上创建并安装计数器代码](https://www.yandex.com/support/metrica/zh/quick-start.md)（如果尚未安装）。
1. 为了让 Yandex Metrica 能够统计页面的重要更改，请分析您的网站逻辑，并在 AJAX 和 Flash 代码的适当部分插入 hit 函数，以便在您认为页面发生更改时将其触发。

```javascript
ym(XXXXXXXX, 'hit', [url[, options]])
```

<!-- source: zh/_includes/objects/hit/id-hit/hit-params.md -->
#|
||
**参数**
|
**默认值**
|
**类型**
|
**描述**
||
||
`url`
|
—
|
String
|
视图所来自的页面的 URL。 如果未提供 URL，则将使用 `window.location.href` 的值。
||
||
`options`
|
—
|
对象
|
—
||
||
`options` 对象的字段
|
>
|
>
|
>
||
||
`options.callback`
|
—
|
Function
|
发送页面浏览数据后调用的回调函数
||
||
`options.ctx`
|
—
|
对象
|
在回调函数中通过 `this` 关键词访问的上下文
||
||
`options.params`
|
—
|
对象
|
会话参数
||
||
`options.referer`
|
—
|
String
|
用户加载当前页面内容的 URL
||
||
`options.title`
|
`document.title`
|
String
|
当前页面的标题
||
||
`options.params` 对象的字段：
|
>
|
>
|
>
||
||
`order_price`
|
—
|
Double
|
Revenue by goal。 您可以用货币或常规单位设置成本。
||
||
`currency`
|
—
|
字符串
|
如果您想以货币形式传递目标成本，请使用此字段。 Yandex Metrica 识别三个字母的 [ISO 4217 货币代码](https://www.six-group.com/en/products-services/financial-information/data-standards.html#scrollTo=currency-codes)。

<!-- source: zh/_includes/ecommerce/data/id-about/currency-note.md -->
如果传递不同的货币，则将发送空值，而不是货币和金额。
<!-- endsource: zh/_includes/ecommerce/data/id-about/currency-note.md -->
||
|#
<!-- endsource: zh/_includes/objects/hit/id-hit/hit-params.md -->



{% list tabs %}

- 对于 AJAX 网站

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

- 对于 Adobe Flash 网站：

  
  对于 ActionScript 2（9.0 之前的 Flash 版本）：
  
  ```javascript
  getURL("javascript:ym(**XXXXXX**, 'hit', url, title, referer)");
  ```
  
  对于 ActionScript 3（9.0 及更高的 Flash 版本）：
  
  ```javascript
  navigateToURL(new URLRequest("javascript:ym(**XXXXXX**, 'hit', url)"), "_self");
  ```

{% endlist %}


如果您想为页面上的特定操作统计[目标](https://www.yandex.com/support/metrica/zh/general/goals.md)完成事件，请使用 reachGoal 函数。



[联系我们](https://yandex.com/chat/#/user/036e6a02-3620-9cdc-4c5e-a34667a7379e?utm_source=spravka){.button}


<!-- source: zh/_includes/footer-links.md -->
- - -

<div class="borderless-table">

#|
||
实用链接

- [演示计数器](https://metrica.yandex.com/r/dashboard?)
- [添加计数器](https://metrica.yandex.com/add/)
- [免费计数器设置](https://yandex.com/promo/freeservice/metrica?utm_source=help_metrica_en&utm_medium=cpc&utm_campaign=1)
- [Yandex Metrica API](https://tech.yandex.com/metrika/)
- [提出您的想法](https://yandex.com/support/metrica/troubleshooting/idea.html)
|
线上培训



- [参加培训课程](https://yandex.com/adv/edu/online/metrika?utm_source=metrika_help&utm_medium=web&utm_campaign=static&utm_content=useful_links)

||
|#

</div>

<!-- source: zh/_includes/styles/table-style.md -->

<!-- endsource: zh/_includes/styles/table-style.md -->
<!-- endsource: zh/_includes/footer-links.md -->

<!-- source: zh/_includes/styles/cut-button.md -->

<!-- endsource: zh/_includes/styles/cut-button.md -->

<!-- source: zh/_includes/styles/href-to-button.md -->

<!-- endsource: zh/_includes/styles/href-to-button.md -->
