# 自定义事件的设置方法

## 自定义事件的设置方法

登录Experience，在管理界面中点击"数据管理">>"获取追踪标签"。

进入"获取追踪标签"画面，点击"事件测量"，复制事件标签。

如果想要更准确地掌握用户行为趋势，请在追踪标签中添加详细信息作为事件标签。请根据需要将标签更改为要测量的信息，如示例标签所示。 **注意：** **事件标签: '值'** 事件标签可以任意定义，值是在事件触发时要获取的指令。

```jsx
ptengine.track('check_out', {
event_label_1: 'value_1',
event_label_2: 'value_2'
});
```

请在事件发生的页面上放置第3步的代码。 如果使用Google Tag Manager，请参阅[通过Google Tag Manager配置](https://gitlab.com/PtmindDev/ptx/ptengine-helps/-/blob/main/DOCS/zh/experience/setting/kasutamuibentono.md)。

如果直接粘贴，请在\</body>之前放置。

## **配置示例**

**示例1：当测量用户点击"Login"按钮的行为作为事件时**

**示例标签1（HTML）：**

```jsx
<button onclick="ptengine.track('事件名')">Login</button>
```

**示例标签2（JavaScript）：**

```jsx
document.getElementById('btnLogin').addEventListener('click', function (){
ptengine.track('事件名');
});
```

**示例2：当测量用户点击"Submit"按钮的行为作为事件，并测量电子邮件地址和注册日期时**

**示例标签1（HTML）：**

```html
<button id="btnSubmit"
    onclick="ptengine.track('事件名', {
	    email: document.getElementById('email').value,　
	    submit_date: new Date()
    });">
submit</button>

```

**示例标签2（JavaScript）：**

```jsx
    document.getElementById('btnSubmit').addEventListener('click', function() {
        ptengine.track('事件名', {
            email: document.getElementById('email').value,
            submit_date: new Date()
        });
    });

```

> 由于追踪标签的配置涉及更改网站的HTML源代码，请由技术人员进行配置，或如需我们的支持，请随时通过聊天等方式与我们联系。

配置完成后，您可以在"数据管理"画面中确认事件的详细信息。

另外，在"事件"或"事件标签"功能中点击"…"编辑按钮，还可以添加说明。


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://helps.ptengine.com/cn/experience/setting/custom-event-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
