> For the complete documentation index, see [llms.txt](https://help.impact.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.impact.com/brand/zh/what-would-you-like-to-learn-about/advocate-program/manage-advocate-participants/custom-and-calculated-fields/calculated-fields-explained.md).

# 计算字段说明

**受限**：计算型自定义字段仅适用于部分产品版本。 [联系支持团队](https://app.impact.com/support/portal.ihtml?createTicket=true&) 以升级您的倡导者计划并获得访问权限。

借助 [自定义字段](https://help.impact.com/brand/zh/what-would-you-like-to-learn-about/advocate-program/manage-advocate-participants/custom-and-calculated-fields/custom-fields-for-advocate-explained.md)，您可以向 impact.com 发送有关倡导者计划参与者的各种额外信息，而不仅限于运行推荐计划所需的基本信息。

计算字段会接收用户和事件数据，并计算和存储相应值，这些值随后会显示在参与者的个人资料中。设置好计算字段后，当您发送符合条件的倡导者计划事件时，其值会动态更新。

{% hint style="info" %}
**示例：** 您可以将计算字段配置为统计参与者在一个月内消费至少 100 美元的购买次数。然后，您可以设置计划，向一个月内至少完成 3 笔此类 100 美元购买的参与者发放特别奖励。
{% endhint %}

#### 默认计算字段

系统默认提供四个计算字段。您可以在开始为计划设置规则时立即引用这些字段。

<details>

<summary>默认计算字段</summary>

| 计算字段               | 说明                                |
| ------------------ | --------------------------------- |
| lastSeenDate       | 跟踪用户最近一次在 Advocate 中执行插入或更新操作的时间。 |
| firstPurchaseDate  | 跟踪我们首次收到该参与者购买事件的日期。              |
| lastPurchaseDate   | 跟踪该参与者最近一次购买事件的日期。                |
| totalPurchaseCount | 跟踪该参与者购买事件的总次数。                   |

</details>

#### 客户创建的计算字段

您可以创建自己的计算字段，扩展默认字段的功能。设置计算字段时，您可以：

* 添加开始日期和结束日期，以便在限定时间内运行计算（例如，从 1 月 1 日到 2 月 17 日）。此时间范围称为有效期。
* 指定重复的 [跟踪窗口](https://help.impact.com/brand/zh/what-would-you-like-to-learn-about/advocate-program/manage-advocate-participants/custom-and-calculated-fields/tracking-windows-for-calculated-fields-explained.md) ，用于求和和计数计算。跟踪窗口可以是固定窗口（例如某一个日历月或年份），也可以是滚动窗口（例如过去 90 天）。
* 通过添加筛选条件或编写 JSONata 表达式，为计算设置额外条件。有关这些选项的详细说明，请参阅文章 [设置计算字段](https://help.impact.com/brand/zh/what-would-you-like-to-learn-about/advocate-program/manage-advocate-participants/custom-and-calculated-fields/set-up-a-calculated-field.md).

{% hint style="info" %}
**注意：** 如果计算字段设有有效期或跟踪窗口，则计算周期结束后，字段值将不再更新。如果计算字段设有有效期（或者求和/计数计算设有跟踪窗口），则计算周期结束后，字段值将不再更新。不过，这些值仍会显示在每位参与者的个人资料中。
{% endhint %}

<details>

<summary>客户创建的计算字段</summary>

创建计算字段时，可以使用多种计算类型。

| 计算类型       | 说明                                          | 示例                                            |
| ---------- | ------------------------------------------- | --------------------------------------------- |
| 求和         | 计算 `{fieldname}` 字段在 `{eventkey}` 事件中的总和    | 统计受邀好友注册后前 30 天内的所有购买金额，并根据消费金额向客户倡导者发放阶梯式奖励。 |
| 计数         | 统计 `{eventkey}` 事件的次数                       | 参与者购买次数超过 10 次时，向其发放奖励。                       |
| 首次出现日期     | 计算首次出现的时间戳： `{eventkey}` 事件                 | 如果参与者在指定日期之前开始购买，则向其发放奖励。                     |
| 最后出现时间（日期） | 计算最近一次 `{eventkey}` 事件的时间戳                  | 如果参与者最近一次购买发生在 5 天内，则向其发放奖励。                  |
| 首次值        | 计算 `{fieldname}` 字段在首次 {eventkey} 事件中的值     | 当参与者首次购买金额较大时，向其发放奖励。                         |
| 最近值        | 计算 `{fieldname}` 字段在最近一次 `{eventkey}` 事件中的值 | 如果参与者最近一次付款金额达到或超过指定值，则向其发放奖励。                |

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.impact.com/brand/zh/what-would-you-like-to-learn-about/advocate-program/manage-advocate-participants/custom-and-calculated-fields/calculated-fields-explained.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
