> For the complete documentation index, see [llms.txt](https://documentation.pushly.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.pushly.com/pushly-ja/integration/webpusshu/sdk/topuraibash.md).

# 同意とプライバシー

SDK には 2 種類のプライバシー制御があります。1 つは同意管理プラットフォーム（CMP）から訪問者の同意を報告すること、もう 1 つは訪問者自身のオプトアウト要求やデータ削除要求に対応することです。このページでは両方を扱い、一般的な同意プラットフォーム向けのレシピも紹介します。

## プライバシー制御の概要

SDK は 4 種類のプライバシー制御を提供し、 [Pushly の Privacy API](https://developers.pushly.com/reference/using-the-subscribers-api) は 5 つ目を提供します。これらはそれぞれ異なる動作をするため、訪問者の要求に合うものを選んでください。

| 訪問者がしたいこと…            | 使用                                                                                                                                                               | 元に戻せますか?                   | データはどうなりますか                           |
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- | ------------------------------------- |
| 同意バナーに答える             | [`同意`](#reporting-consent-from-a-consent-management-platform)                                                                                                    | はい、報告する `許可済み`             | 保持されます。同意が保留中または拒否中の間は、新しいデータは収集されません |
| しばらく通知の受信を停止する        | [`pause_notifications`](https://documentation.pushly.com/pushly-ja/integration/webpusshu/sdk/methods.md#pausing-resuming-a-users-notifications-soft-unsubscribe) | はい、 `resume_notifications` | 保持されます。追跡は継続されます                      |
| 通知と追跡への同意を撤回する        | [`opt_out`](https://documentation.pushly.com/pushly-ja/integration/webpusshu/sdk/methods.md#opting-a-visitor-out)                                                | はい、 `opt_in`               | 保持されます。新しいデータは収集されません                 |
| サイトからデータを削除してもらう      | [`request_user_deletion`](https://documentation.pushly.com/pushly-ja/integration/webpusshu/sdk/methods.md#deleting-a-visitors-data)                              | いいえ                        | 消去済み                                  |
| 既知のユーザーとしてデータを削除してもらう | [Pushly の Privacy API](https://developers.pushly.com/reference/using-the-subscribers-api)                                                                        | いいえ                        | 消去済み                                  |

## 同意管理プラットフォームからの同意の報告

サイトが同意管理プラットフォーム（CMP）を使用している場合は、訪問者の同意を `同意` オプションで各ページに報告し、変更ごとに `同意` コマンドで報告します。すると SDK は、何かを開始する前に待機、撤回、または読み込みを行います。

{% hint style="warning" %}
web SDK 3.8.0 以降が必要です。
{% endhint %}

次を `同意` スニペットの `load` 呼び出しに入れて、SDK が起動する前に SDK に届くようにします:

```javascript
<script src="https://cdn.p-n.io/sdk/web/latest/pushly-sdk.min.js?domain_key=SDK_KEY" async></script>
<script>
  var PushlySDK = window.PushlySDK || [];
  function pushly() { PushlySDK.push(arguments) }
  pushly('load', {
    domainKey: 'DOMAIN_KEY',
    consent: 'pending' // 訪問者はまだバナーに回答していません
  });
</script>
```

CMP が回答したら、または訪問者が選択を変更したら、それを報告します:

```javascript
pushly('consent', 'granted'); // または 'denied'
```

| 値      | SDK が行うこと                                                                                                                                |
| ------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `保留`   | 待機します。何も開始・送信されず、既存のサブスクリプションはそのまま維持されます。その他のコマンドは、同意が報告されるまで保留されます。                                                                     |
| `許可済み` | 通常どおり読み込まれます。以前に同意が拒否されたために訪問者がオプトアウトしていた場合はそれが解除され、通知を引き続き許可しているブラウザーは自動的に再登録されます。                                                      |
| `拒否`   | 何かを開始する前に、訪問者のプッシュサブスクリプションを削除し、Pushly にオプトアウトしたことを伝えます。これは `opt_out` と同じです。撤回対象が何もない訪問者は、何も送信しません。以前の訪問でデバイスに保存されていたイベントと外部 ID は消去されます。 |
| 未設定    | 同意の処理なし: SDK はこれまでどおり動作します。                                                                                                              |

使用 `'pending'` にし、CMP が回答するまで待機してください。 `'denied'` は報告しないでください。まだ回答していないだけの訪問者に対して報告すると、そのサブスクリプションが撤回されます。

## 同意プラットフォームのレシピ

各レシピではスニペットの `load` で `consent: 'pending'` そして回答を `同意` CMP に回答があったらそのコマンドで報告します。CMP が決して応答しない場合、たとえば広告ブロッカーが読み込みを止めている場合は、SDK は待機したままになり、訪問者のデータは変更されません。

{% hint style="warning" %}
プッシュ通知と追跡の同意に該当するカテゴリや目的は、組織が決定します。公開する前に、以下の確認を同意ポリシーに合わせて調整してください。
{% endhint %}

### IAB TCF （`__tcfapi`)

OneTrust、Didomi、Sourcepoint を含む、IAB Transparency & Consent Framework v2 をサポートするほとんどの CMP は `__tcfapi`を公開します。そのイベントを監視し、訪問者の選択が分かったら同意を報告します:

```javascript
if (typeof window.__tcfapi === 'function') {
  window.__tcfapi('addEventListener', 2, function (tcData, success) {
    if (!success) return;

    // 'cmpuishown' はバナーが表示されており、訪問者がまだ回答していないことを意味します: 保留のままにします。
    if (tcData.eventStatus !== 'tcloaded' && tcData.eventStatus !== 'useractioncomplete') return;

    // 目的 1: デバイス上の情報を保存したりアクセスしたりする。
    var granted = !!(tcData.purpose && tcData.purpose.consents && tcData.purpose.consents[1]);

    pushly('consent', granted ? 'granted' : 'denied');
  });
}
```

もしあなたの CMP が Pushly をベンダーとして一覧に載せている場合は、ベンダーの同意も確認してください、 `tcData.vendor.consents[VENDOR_ID]`の前に `'granted'`. GDPR がその訪問者に適用されない場合は、 `tcData.gdprApplies` は `false`です。それを同意として扱うかどうかは、ポリシーで判断してください。

### OneTrust

OneTrust は `OptanonWrapper` そのスクリプトが読み込まれたとき、および訪問者が選択を保存するたびに呼び出します。訪問者がバナーに回答するまで、同意を報告しないでください:

```javascript
var previousOptanonWrapper = window.OptanonWrapper;

window.OptanonWrapper = function () {
  if (typeof previousOptanonWrapper === 'function') previousOptanonWrapper();

  // 訪問者がバナーに回答するまで、保留のままにします。
  if (!window.OneTrust || !window.OneTrust.IsAlertBoxClosed()) return;

  // Pushly の統合先に当たる OneTrust のカテゴリに合わせて C0004 を置き換えてください。
  var activeGroups = (window.OnetrustActiveGroups || '').split(',');

  pushly('consent', activeGroups.indexOf('C0004') !== -1 ? 'granted' : 'denied');
};
```

### グローバル プライバシー コントロール

を送信するブラウザーは [グローバル プライバシー コントロール](https://globalprivacycontrol.org/) シグナルにより `navigator.globalPrivacyControl` を `true`. それをオプトアウトとして扱う場合は、 `'denied'` をスニペット自体に記述し、CMP が何を報告しても拒否のままにしてください:

```javascript
var globalPrivacyControl = navigator.globalPrivacyControl === true;

pushly('load', {
  domainKey: 'DOMAIN_KEY',
  consent: globalPrivacyControl ? 'denied' : 'pending'
});

// CMP のコールバック内:
// pushly('consent', globalPrivacyControl || !granted ? 'denied' : 'granted');
```

## 削除リンク

で開かれたページは `pushly_udr` をアドレスに含むと（たとえば `https://example.com/?pushly_udr`）そのブラウザーの削除を要求します。これは [`request_user_deletion`](https://documentation.pushly.com/pushly-ja/integration/webpusshu/sdk/methods.md#deleting-a-visitors-data) とまったく同じです。ページが報告する同意にかかわらず機能します。

{% hint style="warning" %}
消去は元に戻せません。 `pushly_udr` ニュースレターや共有ページに貼り付けたリンクは、それを開いたすべての読者のデータを消去します。サイトでこのリンクを使わない場合は、無効にしてください。
{% endhint %}

リンクを無効にするには、 `disableUserDeletionUrlTrigger` を SDK の読み込み時に設定します。 `request_user_deletion` どちらの方法でもコードからは引き続き機能します。

```javascript
pushly('load', {
  domainKey: 'DOMAIN_KEY',
  disableUserDeletionUrlTrigger: true
});
```

{% hint style="info" %}
の呼び出し方法については `opt_out`, `opt_in` および `request_user_deletion` を直接使う方法については [SDK メソッド](https://documentation.pushly.com/pushly-ja/integration/webpusshu/sdk/methods.md).
{% endhint %}


---

# 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://documentation.pushly.com/pushly-ja/integration/webpusshu/sdk/topuraibash.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.
