---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.5
alternate:
  - https://yandex.com/support/metrica/en/ecommerce/wordpress.md
  - https://yandex.com/support/metrica/es/ecommerce/wordpress.md
  - https://yandex.com/support/metrica/pt/ecommerce/wordpress.md
  - https://yandex.com/support/metrica/ru/ecommerce/wordpress.md
  - https://yandex.com/support/metrica/tr/ecommerce/wordpress.md
  - https://yandex.com/support/metrica/zh/ecommerce/wordpress.md
  - href: zh/ecommerce/wordpress.md
    type: text/markdown
    title: Markdown version
  - href: ../llms.txt
    type: text/markdown
    title: llms.txt
title: 启用 WordPress 插件
description: 连接 WordPress 插件。
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/support/metrica/zh/llms.txt


# 启用 WordPress 插件

Yandex Metrica 团队开发了一个官方免费插件，用于在网站上安装网站分析计数器。 该插件在 WordPress 5.2.9 及更高版本上运行。

“Yandex Metrica”插件功能：

- 添加默认启用以下选项的新 Yandex Metrica 计数器：
    
    - [E-commerce](https://yandex.com/support/metrica/zh/ecommerce/about.md)
    - [Session Replay](https://yandex.com/support/metrica/zh/webvisor/info.md)
    - [Click map](https://yandex.com/support/metrica/zh/behavior/click-map.md)
    
- 传输 [E-commerce 事件](https://yandex.com/support/metrica/zh/ecommerce/data.md)：
    - 查看项目配置文件。
    - 将商品添加到购物篮。
    - 从购物篮中删除商品。
    - 进行购买。
    
- 提供[已传输产品数据](https://yandex.com/support/metrica/zh/ecommerce/data.md#product_data)的详细信息。

要使用 E-commerce 功能，请在您的网站上安装在线商店插件 [WooCommerce](https://en.wordpress.org/plugins/woocommerce/)。

## 入门 {#start}

1. 如果您还没有 Yandex Metrica 计数器，则[创建一个](https://yandex.com/support/metrica/zh/quick-start.md)。 确保在计数器设置中指定了正确的网站 URL。 要检查这一点，请转到 Yandex Metrica **Settings** 页面。 注意 **Address** 字段值：应显示您要安装插件的网站的 URL。
1. <!-- source: zh/_includes/ecommerce/enabling/id-enabling/3.md -->
   In the tag settings, enable the **E-commerce** option. A container for collecting data from `dataLayer` will be added to the code snippet by default.
   <!-- endsource: zh/_includes/ecommerce/enabling/id-enabling/3.md -->
    
1. 确保 WordPress 中未激活安装 Yandex Metrica 计数器的类似插件。 要检查这一点，请转到 **Plugins** 页面并搜索具有名称“Yandex Metrica”、“Metrica”或“Metrika”的插件。 如果找到一个，请将其取消激活。

## 第 1 步. 安装插件 {#upload}

1. 转到 WordPress 管理面板并登录。
1. 转到 **Plugins** 页面并点击 **Add new** 按钮。
    ![](../_assets/wp-add-new.png){.border-yes}
    
1. 通过以下方式之一添加插件：
    
    {% list tabs %}
    
    - 通过搜索
    
      找到名为“Yandex Metrica”的插件，然后点击 **Install Now** 按钮。
      ![](../_assets/wp-search.png){.border-yes}
    
    - 使用文件
    
      [下载用于插件安装的 ZIP 归档](https://metrika-cms-plugins.s3.yandex.net/wordpress/wp-yandex-metrika.zip)。 接下来，在 **Add Plugins** 页面上，点击 **Upload Plugin**，选择 ZIP 归档并安装。
      ![](../_assets/wp-upload.png){.border-yes}
    
    {% endlist %}
    
1. 转到 **Plugins** → **Installed Plugins** 并找到 Yandex Metrica 插件。 将其激活。

## 第 2 步. 设置插件 {#set}

1. 转到 **Plugins** → **Installed Plugins** 并找到 Yandex Metrica 插件。
1. 打开插件设置。
1. 输入您网站上安装的计数器的编号。 如果该插件在网站上检测到 Yandex Metrica 计数器，则会自动填写这些字段。 检查它们的值是否正确。 [如何找到计数器编号](https://yandex.com/support/metrica/zh/general/tag-id.md)
1. 默认启用 **Session Replay** 选项。 该选项会[录制用户会话](https://yandex.com/support/metrica/zh/webvisor/info.md)，以便您可以更详细地分析统计。 如有必要，您可以随时禁用 Session Replay。
1. 输入 **Brand type**，以便有关您产品品牌的信息能够正确传输到 Yandex Metrica 并显示在报表中。
    - **Term** — 在 **Taxonomy or custom field of brand** 字段中，指定品牌分类法。
    
      {% cut "如何找出品牌分类法" %}
    
      在 WordPress 中，转到 **Products** → **Brands** 页面，查看浏览器地址栏中的 URL — `taxonomy` 参数包含品牌分类名称。 在本例中为 `example-brand`。
      ![](../_assets/wp-tax.png){.border-yes}
    
    
      {% endcut %}
    
    - **Custom field** — 在 **Taxonomy or custom field of brand** 字段中，指定品牌字段的名称。
    
      {% cut "如何找出自定义品牌字段" %}
    
      可以使用负责网站上品牌功能的插件设置该字段。 如果您的网站上有该字段，您可以使用插件文档或联系开发人员的支持服务，以确定该字段的名称。
    
      如果您的 WordPress 主题提供自定义品牌字段，您还可以自行在数据库中查找该字段。
    
      {% endcut %}
    
1. 保存更改。
    ![](../_assets/wp-set-counter.png){.border-yes}

安装并设置插件后，查看错误日志。 如果您有任何疑问，请使用[下方表单](#form)提问或转到 WordPress 上的 Yandex Metrica 插件页面（点击 **Go to Support Forum**）。


{% cut "查看常见错误" %}


- WordPress 版本已过时。 检查是否有新版本并安装。 要执行此操作，请打开管理面板，然后转到 **Dashboard** → **Updates** 页面。
- 网站上缺少指定的品牌分类法。
- 主题缺少插件运行所需的钩子。
- 计数器编号包含非数字字符。


{% endcut %}


## 第 3 步. 检查数据是否已发送 {#check}

检查以下数据是否发送到 Yandex Metrica：

- [E-commerce](https://yandex.com/support/metrica/zh/ecommerce/check.md)。
- [网站会话](https://yandex.com/support/metrica/zh/general/check-counter.md)。

E-commerce 数据在首次发送后显示在 Yandex Metrica 中几个小时。 要查看 e-commerce 报表，请转至 Yandex Metrica 并打开 **Reports** → **E-commerce**。

[E-commerce 报表](https://yandex.com/support/metrica/zh/data/e-commerce-reports.md)

当您安装插件后出现第一个网站会话时，有关会话和页面浏览量的数据会显示在 Yandex Metrica 中。 要查看统计，请转到 Yandex Metrica 并打开 **Reports**。 有关使用报表的更多信息，请参阅[设置和查看报表](https://yandex.com/support/metrica/zh/reports/report-general.md)。

## 更新插件 {#update}

当有新的插件版本时，WordPress 管理面板中会显示一条消息，提示有新版本。 您可以通过以下方式之一安装更新：
- 点击消息中的链接。
- 选择 **Plugins** → **Installed Plugins** 页面上的插件。
- [下载包含更新的 ZIP 归档](https://metrika-cms-plugins.s3.yandex.net/wordpress/wp-yandex-metrika.zip)。 接下来，在 **Add Plugins** 页面上，点击 **Upload Plugin**，选择 ZIP 归档并安装。

## 问题与解答 {#qanda}


{% cut "为什么插件不发送“产品浏览”事件？" %} {#form}

最有可能的情况是，产品页面上的 [Colibri](https://wordpress.org/themes/colibri-wp/) 主题缺少“woocommerce_before_single_product”钩子。 此挂钩是插件正常运行的必要条件。 我们建议将挂钩添加到主题中。

{% endcut %}

<!-- source: zh/_includes/buttons/chat-button.md -->
[与我们聊天](https://yandex.com/chat/#/user/036e6a02-3620-9cdc-4c5e-a34667a7379e?utm_source=spravka){.button}

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

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

<!-- source: zh/_includes/reports/support-button.md -->
[联系我们](https://yandex-ad.cn/contact){.button}


<!-- 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 -->
<!-- endsource: zh/_includes/reports/support-button.md -->

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