> For the complete documentation index, see [llms.txt](https://docs.groobee.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.groobee.ai/ja/developer-guide/script-guide/custom-event.md). Agents can also search and read this documentation through its [MCP server](https://docs.groobee.ai/~gitbook/mcp).

# カスタムイベント

## **1. 概要**

* カスタムイベントでは、管理画面でカスタムイベントキーを作成し、groobeeが標準で提供する行動イベント（event）以外の行動イベント（event）を設定して使えます。
* 設定したカスタムイベントは、セグメントの作成やキャンペーンのトリガーに使えます。
* イベントとは、キャンペーンのクリックや商品の閲覧など、顧客がサイト上で行うアクションを指します。

***

## **2. 主な機能**

* groobee.customEvent
  * この関数で、カスタムイベントに発行されたイベントキーを使って行動データを収集します。
  * 例）groobee.customEvent("イベントキー", "値")
* カスタムイベントは最大30個まで追加できます。新しいイベントが必要な場合は、使っていないイベントを削除してください。

**カスタムイベントの活用例**

| イベント名   | 設置箇所      | イベント内容       |
| ------- | --------- | ------------ |
| ラッキードロー | ラッキードロー A | luckydraw\_A |
|         | ラッキードロー B | luckydraw\_B |
| ダウンロード  | ダウンロード C  | download\_C  |
|         | ダウンロード D  | download\_D  |

{% hint style="info" %}
[**\[カスタム設定 > イベント\]**](https://docs.groobee.ai/ja/admin/settings/custom.md#undefined)を参照してください。
{% endhint %}

***

## **3. カスタム：イベントとデータ**

* カスタムイベントとカスタムデータは、groobeeが標準で提供するセグメント変数のほかに、条件を自由に組み合わせて顧客をターゲティングするときに使います。
* 2つの方式の違いは次のとおりです。

<table><thead><tr><th width="177.57421875"></th><th>カスタムイベント</th><th>カスタムデータ</th></tr></thead><tbody><tr><td>データ連携方法</td><td>JavaScript</td><td>REST API &#x26; JavaScript</td></tr><tr><td>データ連携のタイミング</td><td>自社サイトを訪れた顧客が特定の行動をしたとき</td><td>任意のタイミング</td></tr><tr><td>活用範囲</td><td><p>1. セグメントターゲティングの変数として活用</p><p>2. オンサイトキャンペーン作成時の表示条件の設定<br>オンサイトキャンペーン：ステップ3 オプション設定 > トリガー条件</p></td><td>セグメントターゲティングの変数として活用</td></tr><tr><td>自社サイトに合う方式は？</td><td><p>自社で蓄積したデータはないが、groobeeと連携して、希望する条件に合う顧客をターゲティングしたい。</p><p>→ カスタムイベント</p></td><td><p>自社で保有しているデータを使って顧客をターゲティングしたい。</p><p>→ カスタムデータ</p></td></tr></tbody></table>

***

## **4. カスタムイベントの利用手順**

### **ステップ1**

[**\[設定 > カスタム設定 > イベント\]**](https://docs.groobee.ai/ja/admin/settings/custom.md#undefined)でイベントを追加してください。

### **ステップ2**

groobee関数の呼び出し（groobee.customEvent）：カスタムイベント関数の要件（イベントキーとイベント内容）に沿って、groobeeの関数を呼び出してください。

| **役割**    | カスタムイベント            |        |        |
| --------- | ------------------- | ------ | ------ |
| **関数名**   | groobee.customEvent |        |        |
| **パラメータ** | eventKey            | イベントキー | string |
|           | eventValue          | イベント内容 | string |

**例**

```
groobee.customEvent("eventKey1", "addCart");  

groobee.customEvent("eventKey2", "scroll 80%"); 
```

***

## **※ カスタムイベント利用時の注意事項**

1\. サイトのソースコードで、イベントが発生したときに groobee.customEvent 関数を呼び出すようにしてください。

2\. 関数は、groobeeスクリプトがすべて読み込まれた後（ページの読み込み後）に呼び出してください。

groobee.customEvent("eventKey1", "addCart") を実行した直後にページが遷移するイベントでの利用は避けてください。（ページ遷移時にデータが正しく収集されない場合があります。）

3\. すべての行動イベントが終わり、ユーザーが現在のページにとどまっている状態で使うことをおすすめします。


---

# 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://docs.groobee.ai/ja/developer-guide/script-guide/custom-event.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.
