> For the complete documentation index, see [llms.txt](https://docs.ok-sky.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ok-sky.com/js-sdk/tracker.md).

# tracker

### 概要

来訪者のトラッキングを行うためのJavascript APIです。

* チャットウィジェットと併用して利用します。
* チャットのやり取りをしている利用者がどのページを閲覧しているのか（PVトラッキング）を計測できます。
* コンバージョン等のイベントもトラッキングすることができます

### 対象

* 来訪者用のチャットウィジェットを導入するウェブサイトがある
* HTML / JavaScriptに関する基本的な知識がある

## JS SDKの導入

1. JS SDKの読み込み
2. PV送信
3. 特定のイベント送信

### JS SDKの読み込み方法

```markup
<script src="https://cdn.ok-sky.com/sdk/multi/tracker.js" type="text/javascript"></script>
```

* `<head></head>` 内に記載

### PV送信

```javascript
<script>
  let tracker = new oktag("OK SKYシステムのURL");
  tracker.send({command: "pageview"});
</script>
```

* `<body>` 直後に記載
* OK SKYシステムのURL
  * 接客管理サイトのURLから取得することができます。
  * `https://から始まり、/で終わる` 形で、 `https://{OK SKYシステムのFQDN}/` の形になります。

### 特定のイベント送信

```javascript
<script>
  let tracker = new oktag("OK SKYシステムのURL");
  tracker.send({command: "event", action: "buy", category: "mens", label: "pants", value: 42});
</script>
```

* `<body>` 直後に記載
* OK SKYシステムのURL
  * 接客管理サイトのURLから取得することができます。
  * `https://から始まり、/で終わる` 形で、 `https://{OK SKYシステムのFQDN}/` の形になります。
* `command` は、 `"event"` で固定です。
  * `action` 、 `category` 、 `label` は文字列で任意の情報をしてできます。
  * `value` では、数字を指定してください。


---

# 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 dynamically by asking a question.

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

```
GET https://docs.ok-sky.com/js-sdk/tracker.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
