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

# AgeGOとExoClickを統合する方法

このガイドでは、以下について説明します。

* AgeGO にサイトを登録する方法。
* 年齢確認パラメーターを ExoClick に渡し、広告ゾーンで広告をブロックする方法。
* AgeGO と ExoClick の広告ゾーンを連携し、年齢確認前のユーザーに SFW 広告を表示する方法。

## AgeGO にサイトを登録する方法

AgeGO にサイトを登録するには、 [AgeGO ダッシュボード](https://dashboard.agego.com/login)にログインします。次に、［My Sites］に移動し、［New Site］をクリックします。

![ExoClick AgeGO 1](https://content.gitbook.com/content/GoSwRYjxsR1XS6va6yLj/blobs/bB1LSjp55HpIccLbeC8G/assets/hires/agego-1.png)

これらの設定で、少なくとも **名前** と **トップレベルドメイン**を追加する必要があります。設定が完了したら、［Create］をクリックします。サイトがアカウントに追加されます。

既定では、作成時にすべてのサイトのステータスが「Ready」になります。ただし、これはサイトで AgeGO をまだ利用できるという意味ではありません。サイトで AgeGO を有効にするには、 [**AgeGO のお問い合わせフォームから連絡し**](https://www.agego.com/contact-us-business) **、サイトに対応する Site ID を伝える必要があります。**

Site ID は、サイト名の横に表示されています。

![ExoClick AgeGO 2](https://content.gitbook.com/content/GoSwRYjxsR1XS6va6yLj/blobs/GMJYtpAAJvSxFMxPWlpc/assets/hires/agego-2.png)

サイトが承認されると、ステータスが「Running」に変わり、連携手順に従ってサイトに AgeGO を導入できるようになります。現在、このソリューションでは **モーダル（シンプルまたは高度）** と **S2S**の2つの方法が提供されており、それぞれの設定手順は AgeGO ダッシュボードで確認できます。このガイドでは、 **モーダル** 方式について説明します。

## 年齢確認のステータスを渡し、SFW 広告を配信する方法

年齢確認システム（AgeGO または他のプロバイダー）を使用している場合、年齢確認をしていないユーザーにも、確認済みのユーザーにも、広告を引き続き表示したいことがあるでしょう。

ユーザーが年齢確認を通過したかどうかを示すには、広告ゾーンで `data-ex_av` パラメーターを使用します。このパラメーターには、次の3つの値を指定できます。

* "0": 年齢確認なし（未定義）
* "1": 年齢確認済み
* "2": 年齢未確認

次に、特定のユーザー（ここでは、年齢確認をしていないユーザー）への広告配信をブロックするには、 `data-block-ad-types` パラメーターを使用します。このパラメーターには複数の値を指定できますが、このガイドでは値 `101`.

を使用します。したがって、SFW 広告を配信し、ユーザーがまだ年齢確認をしていないことを示すには、次のようにパラメーターを設定します。

* **非同期広告フォーマット（バナー、FPI、マルチフォーマットなど）：**

```html
<script async type="application/javascript" src="https://a.magsrv.com/ad-provider.js"></script> 
 <ins class="eas6a97888e2" data-zoneid="XXXXXXXX" data-ex_av="2"  data-block-ad-types="101"></ins> 
 <script>(AdProvider = window.AdProvider || []).push({"serve": {}});</script>
```

* **インストリーム**: `https://s.magsrv.com/v1/vast.php?idzone=XXXXXX&ex_av=2&block_ad_types=101`
* **ポップアンダー（リンク）**: `https://s.pemsrv.com/v1/link.php?cat=&idzone=XXXXX&type=8&ex_av=2&block_ad_types=101`
* **ダイレクトリンク**: `https://s.zlinkt.com/v1/d.php?z=XXXXXXX&ex_av=2&block_ad_types=101`

**注意**：両方を使用する必要があります `data-ex_av` および `data-block-ad-types` SFW広告を配信する場合に設定します。設定しないと、ユーザーが正しく識別されず、広告がブロックされません。

認証済みユーザーにあらゆる種類の広告を配信する場合は、次のように設定します。

* **非同期広告フォーマット（バナー、FPI、マルチフォーマットなど）：**

```html
<script async type="application/javascript" src="https://a.magsrv.com/ad-provider.js"></script> 
<ins class="eas6a97888e2" data-zoneid="XXXXXXX" data-ex_av="1"></ins> 
<script>(AdProvider = window.AdProvider || []).push({"serve": {}});</script>
```

* **インストリーム**: `https://s.magsrv.com/v1/vast.php?idzone=XXXXXXXX&ex_av=1`
* **ポップアンダー（リンク）**: `https://s.pemsrv.com/v1/link.php?cat=&idzone=XXXXXXX&type=8&ex_av=1`
* **ダイレクトリンク**: `https://s.zlinkt.com/v1/d.php?z=XXXXXXX&ex_av=`

## SFWエクスペリエンスの作成方法

以下のチュートリアルでは、「SFWエクスペリエンス」の作成方法、つまり、ユーザーがまだ年齢確認を済ませていない場合にSFW広告のみを配信する方法を説明します。この方法はあくまで推奨事項です。異なるユーザーフローに合わせる必要がある場合は、設定を変更できます。

この設定では、別のスクリプトファイルを作成する必要があります。この例では、ファイル名を `main.js`:

```javascript
function getCookie(name) {
  const value = `${document.cookie};`;
  const parts = value.split(`${name}=`);
  if (parts.length !== 2) return false;
  const token = parts.pop().split(";").shift();
  const format = token.split(".");
  if (format.length !== 3) return false;
  try {
    format.slice(0, 2).forEach(part => {
      const padded = part + "=".repeat((4 - part.length % 4) % 4);
      atob(padded.replace(/-/g, "+").replace(/_/g, "/"));
    });
    return true; 
  } catch (e) {
    return false; 
  }
}

function verifier(event, container) {
    window.AGEGO = window.AGEGO || function () {
	(AGEGO.e = AGEGO.e || []).push(arguments)
	};
     AGEGO('configure', {
	siteId: XXXXXXX, // AgeGoに登録したサイトのサイトID
	autoBlur: true,
	verifyMode: 'inline', 
	requireAgeVerification: true, 
	allowDirectContinue: false, 
	overlay: {
		logo: 'wlogo.png', // サイトのロゴ
		theme: 'auto'
		},
	events: {
		onVerificationFlowEnd() {
			console.log("Verification successfull");
			window.location.reload();
			},
            	onVerificationFlowFailed() {
			console.log("Verification failed with errorcode:" + error);
			},
            	onAgeVerify() {
			console.log("Begin Age Verification process");
			},
            	onDirectContinue() {
			console.log("DirectContinue action");
			},
            	onUnderageSkip() {
			console.log("Skipped");
			},
            	onVerifiedBefore() {
			console.log("Verified Before");
			}
		}
	       }
	);

            var n = document.createEvent("Event");
            n.initEvent("DOMContentLoaded", !0, !0),
            document.dispatchEvent(n);
}

const TARGET_SELECTOR = '.main, .footer; // replace with classes where click will be intercepted

function intercept(e) {
   const container = e.target.closest(TARGET_SELECTOR);
   if (!container) return; 
        
   e.preventDefault();
   e.stopImmediatePropagation(); 
   e.stopPropagation();

   verifier(e, container);
}
```

このファイルには3つの関数が含まれています。Cookieを検出する関数、AgeGOオーバーレイを読み込む関数、特定のクラス上でのクリックを検出する関数です。この例では、次のクラスを使用しています。 `.main` と `.footer`.

次に、サイトのHTMLに以下を配置します。

```html
<!--AgeGoのコード-->
<script src="https://verifycdn.agego.com/v1/verify.js"></script>

<!-- カスタム関数のコード-->
<script src="main.js"></script>

<!-- 広告プロバイダーのコード-->
<script async type="application/javascript" src="https://a.magsrv.com/ad-provider.js"></script>

<!-- 広告ゾーン。XXXXとYYYYYは、管理パネルで指定されたクラスIDとゾーンIDに対応します。 -->
<div id="videontv">
  <ins class="XXXXXX" data-zoneid="YYYYYY" data-block-ad-types="101"  data-ex_av="2"></ins> 
  <ins class="XXXXXX" data-zoneid="YYYYYY" data-block-ad-types="101"  data-ex_av="2"></ins> 
</div>

<!-- 適切なパラメーターで広告を配信するコード-->
<script>
	const agegoValue = getCookie("agego_aver");
	if (agegoValue !== false)  {
               console.log("user verified");
        	   const adInsElements = document.querySelectorAll("ins");
        	   adInsElements.forEach(ins => {
            	ins.setAttribute("data-ex_av", "1");
            	ins.setAttribute("data-block-ad-types", "0");
        		});
    	   }
             else {
                 console.log("user not verified");
                 ['pointerdown', 'click', 'touchstart'].forEach(type => {
                 document.addEventListener(type, intercept, { capture: true });
                 });
             }
	(AdProvider = window.AdProvider || []).push({"serve": {}});
</script>
```

この例では、 **ユーザーが年齢を確認するまでは、広告はデフォルトでSFW（職場で閲覧可能）です**。前述の選択したクラスをユーザーがクリックすると、AgeGOオーバーレイが表示されます。ユーザーが年齢を確認すると、 **ページは通常どおり読み込まれ、今度は広告がブロックされません。**.

***

このチュートリアルに関する注意事項をいくつか紹介します。

1. この設定では、AgeGO が設定する `agego_aver` Cookie を利用します。ただし、変更することもできます。AgeGO スクリプトのイベントを使って localStorage に値を設定し、その値に基づいて表示する広告を決定できます。
2. どちらの方法も広告配信のみを対象としています。このコードでは、動画のサムネイルやその他のウェブサイトのコンテンツは考慮されません。
3. 現在、AgeGO には国を検出する機能が組み込まれていません。このコードをいつ表示するかは、ご自身で決める必要があります。

***

任意のイベントに応じて `data-ex_av` と `data-block-ad-types` を設定したい場合は、次のチュートリアルもご覧ください。 [広告タイプを動的にブロックする](https://docs.exoclick.com/tutorials/ja/chtoriaru/paburisshkechtoriaru/dynamically-block-ads-using-data-block-ad-types.md), [インストリーム広告ゾーンで広告タイプを動的にブロックする](https://docs.exoclick.com/tutorials/ja/chtoriaru/paburisshkechtoriaru/dynamically-block-ad-types-for-exoclick-in-stream-zones.md).

最後に、年齢確認ソリューションを使った、より汎用的な広告ゾーンの連携については、 [こちらの別のチュートリアルをご覧ください。](https://docs.exoclick.com/tutorials/ja/chtoriaru/paburisshkechtoriaru/serve-sfw-ads.md)


---

# 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.exoclick.com/publishers/ja/exoclick-agego.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.
