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


# 启用 1C-Bitrix 模块

Yandex Metrica 团队开发了一个官方免费模块，用于在网站上安装 Web 分析计数器。 该模块运行在 1C-Bitrix 18.0 及更高版本上，并支持所有“1C-Bitrix: Site Management”版本。

“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)的详细信息。

## 安装和设置模块 {#general}

### 入门 {#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. 确保 1C-Bitrix 中没有激活安装 Yandex Metrica 计数器的类似模块。 在管理面板中，打开 **Marketplace** → **Solutions installed**，搜索名为“Yandex Metrica”、“Metrica”或“Metrika”的模块。 如果有，请将其删除。

### 第 1 步. 安装模块 {#upload}

转至 1C-Bitrix 管理面板，登录并使用以下方法之一添加模块：


{% cut "通过管理面板" %}


1. 打开 **Marketplace** → **Solutions installed**，找到名为“Yandex Metrica”的模块。
1. 点击图标并选择 **Install now**。
    

{% endcut %}

{% cut "Via 1C-Bitrix: Marketplace" %}


1. 转到 [1C-Bitrix: Marketplace](http://marketplace.1c-bitrix.ru/solutions)，并找到名为“Yandex Metrica”的模块。
1. 打开模块并点击 **Install**。


{% endcut %}

{% cut "使用 ZIP 归档" %} {#zip}


1. 下载带有 [UTF8](https://metrika-cms-plugins.s3.yandex.net/1c-bitrix/yandex.metrika.utf8.zip) 或者 [CP1251](https://metrika-cms-plugins.s3.yandex.net/1c-bitrix/yandex.metrika.cp1251.zip) 编码的安装 ZIP 归档。
1. 转到 1C-Bitrix 管理面板（在 **Content** 页面上）。
1. 选择 **Files and folders** → **bitrix** → **modules** 部分并打开模块列表的最后一页。
1. 点击 **Upload** → **Add file** 并选择包含 Yandex Metrica 模块的 ZIP 归档。
1. 点击 **Save**。 归档将上传至您服务器上的 `modules` 目录。
1. 解压缩归档：在模块列表中找到它，点击 ![](../_assets/bitrix-menu.png) 并选择**Unpack**。 确保 `yandex.metrika` 目录显示在列表中。
1. 打开 **Marketplace** → **Solutions installed**，找到名为“Yandex Metrica”的模块。 点击 ![](../_assets/bitrix-menu.png) 并选择 **Install**。


{% endcut %}


### 第 2 步. 设置模块 {#set}

1. 转到 **Settings** → **Product settings**→ **Module settings**→ **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. 保存更改。
    


{% note tip %}

**Brand Property** 字段不是强制性的。 如果您想在 Yandex Metrica 中跟踪商品品牌的统计数据，则[填写该字段](#brand)。 例如，哪个品牌最受客户欢迎。
此外，要获得有关商品的更详细的统计数据（例如，用户最常浏览哪些商品），则[配置 detail 事件](#detail)。

{% endnote %}


### 第 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)。


## 其他设置 {#func}

### 如何在模块设置中填写“Brand Property”字段 {#brand}

您可以将有关您在线商店中的品牌的信息发送至 Yandex Metrica。 根据此数据，Yandex Metrica[生成报表](https://yandex.com/support/metrica/zh/reports/popular-brands.md)，您可以使用它来确定最受客户欢迎的品牌或找出哪个品牌带来最多的利润等。


{% note info %}

1C-Bitrix 模板可以有多个商品目录。 在 Yandex Metrica 模块设置中，仅显示活动目录的品牌属性。 我们建议填写所有可用的 **Brand Property** 字段以确保数据正确发送到 Yandex Metrica。

{% endnote %}


要查找属性值：
1. 转到 1C-Bitrix 管理面板。
1. 转到 **Content** → **Types of infoblocks** → **Catalogs** 并选择目录。
1. 打开右侧的 **Features** 选项卡。
1. 在列表中，找到品牌对应的字段。
1. 在“Yandex Metrica”模块设置中指定字段的名称。


### 如何传输有关商品浏览的信息（detail 属性） {#detail}

您可以将商品浏览数据发送到 Yandex Metrica，以便 E-commerce 报表包含更详细的信息。 例如，[Popular items 报表](https://yandex.com/support/metrica/zh/reports/popular-goods.md)就是这样形成的。

要配置产品浏览事件，您需要修改您网站上 `bitrix:catalog` 组件模板中 `element.php` 文件的代码。


{% note alert %}

`element.php` 文件的路径在不同网站模板中可能有所不同。

{% endnote %}


1. 以管理员身份登录网站。
1. 在 **Website** 选项卡上，打开 **Editing mode**。
    
    {% note info %}
    
    如果您之前编辑过模板，请转到本指南的第 6 步。
    
    {% endnote %}
    
1. 在网站上，打开商品卡并将鼠标悬停在目录组件区域上以打开菜单。
1. 点击 ![](../_assets/bitrix-set-icon.png)，选择目录，然后选择 **Copy the component template**。
1. 在 **Copy to the site template** 字段中，选择 **current** 并保存更改。
1. [找到](#found-element)并打开 `element.php` 文件。 在代码中，找到如下所示的行：
    ```php
    $elementId = $APPLICATION->IncludeComponent('bitrix:catalog.element', 'bootstrap_v4', $componentElementParams,
    $component
    );
    ```
    
    如果在 `bitrix:catalog.element` 组件前未看到 `"$elementId = "`，请手动将该变量添加到代码中。
    
1. 在其后，添加 `$APPLICATION->IncludeComponent("yandex.metrika:detail", "", array("PRODUCT_ID" => $elementId), $component);`。
    检查 `detail` 代码中的变量和函数使用的大小写是否与 `element.php` 文件一致。
    
    {% cut "代码示例" %}
    
    ```php
    ...
    $elementId = $APPLICATION->IncludeComponent('bitrix:catalog.element', 'bootstrap_v4', $componentElementParams,
    $component
    );
    $APPLICATION->IncludeComponent("yandex.metrika:detail", "", array("PRODUCT_ID" => $elementId), $component);
    ...
    ```
    
    {% endcut %}
    
1. 点击 **Save**。


{% cut "如何查找 element.php 文件" %} {#found-element}


1. 在 **Website** 选项卡上，打开 **Editing mode**。
1. 在网站上，打开商品卡并将鼠标悬停在目录组件区域上以打开菜单。
1. 点击 ![](../_assets/bitrix-set-icon.png)，选择目录，然后选择 **Edit the component template**。
1. 确保 `element.php` 文件显示在打开的窗口中。 文件的路径在窗口名称中指定。


{% endcut %}


安装并设置模块后，查看错误日志。 为此，请在 1C-Bitrix 管理面板中打开该模块。 您可以通过[以下表单](#form)或在 1C-Bitrix 网站上（在右下角，点击 **Technical support**）提出任何问题。


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


- 1C-Bitrix 的过时版本。 检查是否有新版本并安装。 为此，请打开管理面板并转到 **Marketplace** → **Platform update**。
- 您指定的品牌属性不在网站上。
- 计数器编号包含非数字字符。


{% endcut %}



## 许可协议 {#licens}

阅读[许可协议](https://metrika-cms-plugins.s3.yandex.net/1c-bitrix/LICENSE.txt)了解有关将“Yandex Metrica”模块用于 1C-Bitrix 的信息。


## 更新模块 {#update}

当模块有新版本时，相关消息将显示在 1C-Bitrix 管理面板中。 您可以通过以下方式之一安装更新：
- 点击消息中的链接。
- 选择 **Marketplace** → **Solutions installed** 页面上的模块。
- 在 [1C-Bitrix: Marketplace](https://marketplace.1c-bitrix.ru/) 页面上。
- 下载带有 [UTF8](https://metrika-cms-plugins.s3.yandex.net/1c-bitrix/yandex.metrika.utf8.zip)或者 [CP1251](https://metrika-cms-plugins.s3.yandex.net/1c-bitrix/yandex.metrika.cp1251.zip) 编码的更新 ZIP 归档并[按照安装文件的说明进行操作](#zip)。

<!-- 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/support-2.md -->
<div class="cut-button">

{% cut "发送电子邮件" %}

<!-- source: zh/_includes/popup/id-popup/wrong-sup.md -->
请注意：我们的支持团队永远不会主动给您打电话。 请勿按照自称为 Yandex Metrica 支持团队来电者的指示操作。
<!-- endsource: zh/_includes/popup/id-popup/wrong-sup.md -->

<div style="padding: 15px;
     margin: 10px 0;
     background: #FFFFFF;
     border-radius: 10px;
     border: 1px solid var(--yc-color-line-generic);">
  <iframe style="background: #FFFFFF;"
        height="700"
        width="100%"
        frameborder="0"
        src="https://forms.yandex.com/surveys/10011833/?&iframe=1&lang=en">
  </iframe>
</div>

{% endcut %}

</div>

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

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