# カスタムイベントの設定方法

## カスタムイベントの設定方法

1. Experienceにログインし、管理画面にある「データ管理」>>「トラッキングタグを取得」をクリックしてします。

   ![](/files/8W2eXPspRlS3vqlvRTPm)
2. 「トラッキングタグを取得」画面に入り、「イベント計測」をクリックし、イベントタグをコピーします。

   ![](/files/JWacWpjUXpLPNL8QbNlf)
3. 更にユーザー行動トレンドを正確に把握したい場合、トラッキングタグでイベントラベルとしての詳細情報を追加しましょう。サンプルタグのように、必要に応じてタグを計測したい情報へ変更してください。

   <mark style="color:purple;">**Note：**</mark>**イベントラベル: '値'**

   イベントラベルは任意に定義でき、値はイベント発火時に取得する指示を書き入れます。

   イベントラベルの詳細については[こちら](/experience/setting/event-labels.md#ibentoraberutoha)の記事をご参照ください。

   ```jsx
   ptengine.track('check_out', {
   event_label_1: 'value_1',
   event_label_2: 'value_2'
   });
   ```
4. 3のコードをイベントが発生するページ設置してください。
   1. Google Tag Managerを利用している場合、[Google Tag Manager経由で設定](https://gitlab.com/PtmindDev/ptx/ptengine-helps/-/blob/main/DOCS/start-guide/tag-gtm.md#ptenginenotaguwogoogle-tag-manager-gtm-nisuru)をご参照ください。
   2. 直貼りの場合は\</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()
        });
    });

```

{% hint style="warning" %}
トラッキングタグの設定はサイトのhtmlソースコードを変更することになるため、技術者の方に設定して頂くか、弊社サポートが必要な場合はチャットなどによりお気軽にお問い合わせください。
{% endhint %}

設定完了後「データ管理」画面でイベントの詳細情報を確認できます。

また「イベント」や「イベントラベル」機能で「…」編集ボタンをクリックすると、説明も追加できます。

![](/files/cO8AoQQFXnIWjnW7nyyR)


---

# 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/experience/setting/event-tracking.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.
