はじめに
この API には、[プライバシーとメッセージ] タブで提供されるメッセージを操作するためのツールが用意されています。Metrics Explorer では次の作業を行うことができます。
- 特定のユーザーへのメッセージを抑制する
- ユーザーの広告ブロック ステータスをクエリする
- ユーザーが EU 規制の同意を取り消せるようにするエントリポイントをレンダリングする
- 米国の州規制に関するデフォルトの「販売しない」リンクをオーバーライドする
- EU 規制の Google 同意モードのステータスに基づいて、Google 広告タグと Google アナリティクス タグを条件付きで読み込む
行うことができます
これらのツールを使用して、業界標準のプロトコルを使用してユーザーの同意を収集することもできます。
- IAB TCF v2 仕様を使用した GDPR 同意
- IAB GPP 仕様を使用した米国の州規制のオプトアウト
このような場合、同意ステータスはこれらの API を介して伝達されます。
このユーザー メッセージ機能をサイトにデプロイするには、次の 2 つの方法があります。
- ほとんどの場合、タグを再設定する必要はありません。関連するサービスでメッセージが公開されると、既存の Google パブリッシャー タグまたは AdSense タグによってユーザー メッセージが配信されます。
- 広告ブロックによる損失収益の回復メッセージを使用している場合は、広告ブロックタグをページに明示的に追加する必要があります。詳しくは、アド マネージャーと AdSense のタグ設定手順をご覧ください。
googlefc は、ユーザー メッセージ機能が JavaScript Window の API で使用するグローバル名前空間です。
フィールドの概要
| 名前 | タイプ | 定義 |
|---|---|---|
googlefc.controlledMessagingFunction
|
function(!Object) | メッセージングを続行するかどうかを決定する関数。この機能は、すべてのメッセージ タイプでサポートされています。 |
googlefc.callbackQueue
|
!Array<!Object<string, function()>> | !Array<function()> | !googlefc.CallbackQueue | ユーザー メッセージ クエリの非同期実行用のコールバック キューへの参照。 |
googlefc.CallbackQueue
|
!Object | コールバック キュー オブジェクトのタイプ。 |
googlefc.AdBlockerStatusEnum
|
!Object<string, number> | ユーザーの広告ブロッカーの状態を表す列挙型。 |
googlefc.AllowAdsStatusEnum
|
!Object<string, number> | ユーザーの広告許可状態を表す列挙型。 |
googlefc.usstatesoptout.InitialUsStatesOptOutStatusEnum
|
!Object<string, number> | ユーザーの最初の米国州のオプトアウト ステータスを表す列挙型。この場合、ユーザーが所在する米国の州が考慮されます。 |
googlefc.GoogleFcConsentModeUserStatus
|
!Object |
googlefc.getGoogleConsentModeValues の戻り値の型。 |
googlefc.ConsentModePurposeStatusEnum
|
!Object<string, number> | 同意モードの目的に対するエンドユーザーの決定を表す列挙型。 |
googlefc.usstatesoptout.overrideDnsLink
|
undefined|boolean | 独自のカスタム「個人情報の販売または共有を拒否する」リンクを使用する場合は、true に設定できるブール値。 |
googlefc.ccpa.InitialCcpaStatusEnum
以前のバージョン。 googlefc.usstatesoptout.InitialUsStatesOptOutStatusEnum を優先します。
|
!Object<string, number> | ユーザーの米国の州規制の初期ステータスを表す列挙型。 |
googlefc.ccpa.overrideDnsLink
以前のバージョン。 googlefc.usstatesoptout.overrideDnsLink を優先します。
|
undefined|boolean | 独自のカスタム「個人情報の販売または共有を拒否する」リンクを使用する場合は、true に設定できるブール値。 |
メソッドの概要
| 名前 | 戻り値の型 | 定義 |
|---|---|---|
googlefc.showRevocationMessage()
|
undefined |
同意レコードを消去し、googlefc スクリプトを再読み込みして、ユーザーに適用される同意メッセージを表示します。
|
googlefc.getAdBlockerStatus()
|
数値 |
ユーザーの広告ブロック ステータスに応じて、AdBlockerStatusEnum の値を返します。
|
googlefc.getAllowAdsStatus()
|
数値 |
ユーザーの広告許可ステータスに応じて、AllowAdsStatusEnum の値を返します。
|
googlefc.usstatesoptout.getInitialUsStatesOptOutStatus()
|
数値 |
ユーザーの米国の州規制に関するオプトアウトの初期ステータスに応じて、InitialUsStatesOptOutStatusEnum の値を返します。これは、ユーザーの現在の所在地に基づいて適用される規制を考慮したものです。
|
googlefc.usstatesoptout.openConfirmationDialog(function(boolean))
|
undefined | デフォルトの「販売、共有しない」リンクがオーバーライドされている場合、米国の州規制のオプトアウト確認ダイアログを開きます。 |
googlefc.getGoogleConsentModeValues()
|
!Object |
ユーザーの現在の同意モードの値を含む googlefc.GoogleFcConsentModeUserStatus オブジェクトを返します。利用可能な同意モードの目的ごとに 1 つずつ返されます。 |
googlefc.ccpa.getInitialCcpaStatus()
以前のバージョン。 googlefc.usstatesoptout.getInitialUsStatesOptOutStatus() を優先します。
|
数値 |
ユーザーの米国の州規制に関するオプトアウトの初期ステータスに応じて、InitialCcpaStatusEnum の値を返します。
|
googlefc.ccpa.openConfirmationDialog(function(boolean))
以前のバージョン。 googlefc.usstatesoptout.openConfirmationDialog() を優先します。
|
undefined | デフォルトの「販売、共有しない」リンクがオーバーライドされている場合、米国の州規制のオプトアウト確認ダイアログを開きます。 |
サイトでのテストとデバッグ
プライバシーとメッセージには、デバッグとテストの機能が用意されています。この機能を使用すると、特定のメッセージ、メッセージのサブタイプ、メッセージの組み合わせが実際のサイトでどのように表示されるかを確認できます。
前提条件:
- プレビューするメッセージが、テスト対象のサイトで公開されている必要があります。
次のデバッグ URL パラメータを使用すると、サイトでライブ プレビューを表示できます。
| デバッグ パラメータ | 使用できる値 |
|---|---|
fc |
alwaysshow(デバッグ/プレビュー モードをトリガーする) |
fctype |
ab(広告ブロック メッセージ)、ccpa(米国の州規制に関するオプトアウト メッセージ)、gdpr(GDPR 同意メッセージ)、monetization(オファーウォール メッセージ)、usfl(米国の州規制に関するオプトアウト メッセージ、フロリダ州固有)、usnat(米国の州規制に関するオプトアウト メッセージ、フロリダ州以外のサポートされているすべての州、ccpa と同等) |
サイト(foo.com)でプレビューする際の使用例をいくつか紹介します。
- 米国の州規制に関するオプトアウト メッセージをテストする --
http://foo.com/?fc=alwaysshow&fctype=ccpa - GDPR メッセージをテストする --
http://foo.com/?fc=alwaysshow&fctype=gdpr
フィールド: 説明と例
googlefc.controlledMessagingFunction {function(!Object)}
メッセージを表示するかどうかを決定する関数。これを使用すると、購読者のステータスやページの URL など、パブリッシャーが指定した条件でメッセージのレンダリングを制限できます。
他のスクリプトが読み込まれる前に Window で googlefc.controlledMessagingFunction を定義すると、message.proceed(boolean) を呼び出すまでメッセージは表示されません。message.proceed(true) を呼び出すと、メッセージは通常どおり表示されます。message.proceed(false) を呼び出すと、そのページビューではメッセージが表示されなくなります。
たとえば、ログインしているユーザーが購読者かどうかを確認する非同期関数 determineIfUserIsSubscriber() を定義するスクリプトがページにあるとします。
<head>
<script>
window.isSubscriber = undefined;
function determineIfUserIsSubscriber() {
if (isSubscriber !== undefined) {
return isSubscriber;
}
return new Promise(resolve => {
setTimeout(() => {
// Change this to true if you want to test what subscribers would see.
window.isSubscriber = false;
resolve(window.isSubscriber);
}, 1000);
});
}
</script>
</head>
これは、googlefc.controlledMessagingFunction を使用して、定期購入者以外にのみメッセージを表示する方法の例です。
<head>
<script>
// Define googlefc and the controlled messaging function on the Window.
window.googlefc = window.googlefc || {};
googlefc.controlledMessagingFunction = async (message) => {
// Determine if the user is a subscriber asynchronously.
const isSubscriber = await determineIfUserIsSubscriber();
if (isSubscriber) {
// If the user is a subscriber, don't show any messages.
message.proceed(false);
} else {
// Otherwise, show messages as usual.
message.proceed(true);
}
}
</script>
</head>
この機能の拡張機能として、特定のメッセージ タイプのみを抑制するように指定することもできます。この機能拡張を使用すると、他のメッセージ タイプを抑制することなく、特定のメッセージ タイプを抑制できます。
メッセージ タイプ固有の制御されたメッセージングは、googlefc.MessageTypeEnum 型の Array である message.proceed() に追加のパラメータを渡すことで実現されます。
例: googlefc.controlledMessagingFunction を使用して、他のメッセージ タイプを抑制せずに、定期購入者に対するオファーウォールの配信のみを抑制する例を次に示します。
<head>
<script>
// Define googlefc and the controlled messaging function on the Window.
window.googlefc = window.googlefc || {};
googlefc.controlledMessagingFunction = async (message) => {
// Determine if the Offerwall should display or not.
const shouldDisplayOfferwall = await determineIfUserIsSubscriber();
const applicableMessageTypes = [];
if (!shouldDisplayOfferwall) {
// Do not show the Offerwall, but allow other message types to display.
applicableMessageTypes.push(window.googlefc.MessageTypeEnum.OFFERWALL);
message.proceed(false, applicableMessageTypes);
} else {
// Otherwise, show messages as usual.
message.proceed(true);
}
}
</script>
</head>
メッセージング関連の呼び出しを非同期で実行するためのグローバル コールバック キューへの参照。関数を呼び出す唯一のサポートされている方法は、関数を callbackQueue に追加することです。
異なるタイプのデータは異なるタイミングで利用可能になるため、関数はマップとして追加する必要があります。このマップでは、次のいずれかの文字列をキーとし、実行する関数を値とします。
サポートされているキー:
| キー名 | 用途 | 相対レイテンシ |
|---|---|---|
CONSENT_API_READY
|
CONSENT_API_READY キーを使用してコールバック キューにプッシュされた関数は、サポートされている同意フレームワークの API が定義され、呼び出し可能になったときに実行されます。この時点以降、追加された CONSENT_API_READY キー付き関数の実行は同期的になります。フレームワーク固有の詳細については、 IAB フレームワークのセクションをご覧ください。
|
低 |
CONSENT_DATA_READY
|
CONSENT_DATA_READY キーを使用してコールバック キューにプッシュされた関数は、サポートされている同意フレームワークで収集されたユーザーの同意が判明したときに実行されます(以前の実行から判明した場合、またはユーザーが同意メッセージを操作した場合)。この時点以降、追加された CONSENT_DATA_READY キー付き関数の実行は同期的になります。
|
高 |
AD_BLOCK_DATA_READY
|
AD_BLOCK_DATA_READY キーを使用してコールバック キューにプッシュされた関数は、広告ブロックデータがフローで使用可能になったときに実行されます。この時点以降、追加された AD_BLOCK_DATA_READY キー付き関数の実行は同期的になります。
|
高 |
CONSENT_MODE_DATA_READY
|
CONSENT_MODE_DATA_READY キーを使用してコールバック キューにプッシュされた関数は、Google [同意モード](https://support.google.com/google-ads/answer/10000067) データ(Google 広告タグとアナリティクス タグで使用)がフローで使用可能になったときに実行されます。同意モードのデータが準備できたら、googlefc.getGoogleConsentModeValues を使用していつでも同意モードの値にアクセスできます。
|
中 |
INITIAL_US_STATES_OPT_OUT_DATA_READY
|
INITIAL_US_STATES_OPT_OUT_DATA_READY キーを使用してコールバック キューにプッシュされた関数は、米国の州規制データがフローで使用可能になったときに実行されます。なお、米国の州規制データのその後のリクエストは、GPP API(__gpp)を直接呼び出して取得する必要があります。
|
中 |
INITIAL_CCPA_DATA_READY
|
米国の州規制の以前のキー。INITIAL_US_STATES_OPT_OUT_DATA_READY を優先します。 INITIAL_CCPA_DATA_READY キーを使用してコールバック キューにプッシュされた関数は、米国の州規制データがフローで使用可能になったときに実行されます。なお、米国の州規制データのその後のリクエストは、GPP API(__gpp)を直接呼び出して取得する必要があります。
|
中 |
googlefc.CallbackQueue {!Object}
メソッドの概要:
| 名前 | タイプ | パラメータ | 戻り値の型 | ロール |
|---|---|---|---|---|
push(data)
|
数値 |
data: Key-Value ペア。キーはデータ可用性タイプのいずれかで、値は実行される JavaScript 関数です。使用できるデータ可用性キーは、CONSENT_API_READY、CONSENT_DATA_READY、AD_BLOCK_DATA_READY、INITIAL_US_STATES_OPT_OUT_DATA_READY、CONSENT_MODE_DATA_READY、(以前の)INITIAL_CCPA_DATA_READY です。
|
これまでに作成されたコマンドの数。これにより、配列の現在の長さが返されます。 | 渡された関数を、データが利用可能になった順序で実行し、次にこれらの関数がキューに追加された順序で実行します。 |
例:
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.usstatesoptout = window.googlefc.usstatesoptout || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Queue the callback on the callbackQueue.
googlefc.callbackQueue.push({
'AD_BLOCK_DATA_READY':
() => {
if (googlefc.getAdBlockerStatus() == googlefc.AdBlockerStatusEnum.NO_AD_BLOCKER) {
// Handle a non-ad blocking user.
}
}
});
</script>
googlefc.AdBlockerStatusEnum {!Object<string, number>}
ユーザーのさまざまな広告ブロックの状態を表します。さまざまな状態は次のとおりです。
googlefc.AdBlockerStatusEnum = {
// Something failed, in an unknown state.
UNKNOWN: 0,
// The user was running an extension level ad blocker.
EXTENSION_AD_BLOCKER: 1,
// The user was running a network level ad blocker.
NETWORK_LEVEL_AD_BLOCKER: 2,
// The user was not blocking ads.
NO_AD_BLOCKER: 3,
};
googlefc.AllowAdsStatusEnum {!Object<string, number>}
ユーザーの広告ブロックの広告許可状態を表します。状態には次のものがあります。
googlefc.AllowAdsStatusEnum = {
// Something failed, in an unknown state.
UNKNOWN: 0,
// User is currently using an ad blocker, was never using an ad blocker, or
// allowed ads, but not because they saw the Privacy & messaging message.
ADS_NOT_ALLOWED: 1,
// User is no longer using an ad blocker after seeing the ad blocking message.
ADS_ALLOWED: 2,
};
googlefc.usstatesoptout.InitialUsStatesOptOutStatusEnum{!Object<string, number>}
ユーザーの米国の州規制に関するオプトアウト ステータスを表します。ステータスは次のとおりです。
googlefc.usstatesoptout.InitialUsStatesOptOutStatusEnum = {
// Something failed, status unknown.
UNKNOWN: 0,
// No US state regulation applies to this user.
DOES_NOT_APPLY: 1,
// A US state regulation applies to this user, and the user has not opted out yet.
NOT_OPTED_OUT: 2,
// A US state regulation applies to this user, and the user has opted out.
OPTED_OUT: 3,
};
googlefc.GoogleFcConsentModeUserStatus{!Object}
googlefc.getGoogleConsentModeValues によって返されるオブジェクトのタイプ。
interface GoogleFcConsentModeUserStatus {
// End user consent decision value for the ad_storage consent mode purpose.
adStoragePurposeConsentStatus: number;
// End user consent decision value for the ad_user_data consent mode purpose.
adUserDataPurposeConsentStatus: number;
// End user consent decision value for the ad_personalization consent mode purpose.
adPersonalizationPurposeConsentStatus: number;
// End user consent decision value for the analytics_storage consent mode purpose.
analyticsStoragePurposeConsentStatus: number;
}
各フィールドの値は、googlefc.ConsentModePurposeStatusEnum 列挙型値に対応する数値です。
googlefc.ConsentModePurposeStatusEnum{!Object<string, number>}
同意モードの目的に応じて、エンドユーザーが選択できるさまざまな同意値を表します。値は次のとおりです。
googlefc.ConsentModePurposeStatusEnum = {
// Indicates either an error state, or that consent mode data is not ready
// yet.
UNKNOWN: 0,
// Consent is granted for the given consent mode purpose.
GRANTED: 1,
// Consent is denied for the given consent mode purpose.
DENIED: 2,
// Consent is not applicable for the given consent mode purpose.
NOT_APPLICABLE: 3,
// The consent mode purpose has not been configured for use in the Privacy &
// messaging UI.
NOT_CONFIGURED: 4
};
googlefc.usstatesoptout.overrideDnsLink{undefined|boolean}
デフォルトの「個人情報の販売または共有を許可しない」リンクを非表示にして、独自のカスタム「個人情報の販売または共有を許可しない」リンクを使用するには、このフィールドを true に設定します。この機能はアド マネージャーでのみサポートされています。
例:
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.usstatesoptout = window.googlefc.usstatesoptout || {};
// Signals that the default DNS link will be overridden.
googlefc.usstatesoptout.overrideDnsLink = true;
</script>
googlefc.ccpa.InitialCcpaStatusEnum{!Object<string, number>}
ユーザーの米国の州規制に関するオプトアウト ステータスを表します。ステータスは次のとおりです。
googlefc.ccpa.InitialCcpaStatusEnum = {
// Something failed, in an unknown state.
UNKNOWN: 0,
// No US state regulation applies to this user.
CCPA_DOES_NOT_APPLY: 1,
// A US state regulation applies to this user, and the user has not opted out yet.
NOT_OPTED_OUT: 2,
// A US state regulation applies to this user, and the user has opted out.
OPTED_OUT: 3,
};
googlefc.ccpa.overrideDnsLink{undefined|boolean}
デフォルトの「個人情報の販売または共有を許可しない」リンクを非表示にして、独自のカスタム「個人情報の販売または共有を許可しない」リンクを使用するには、このフィールドを true に設定します。このフィールドを true に設定した場合は、サイトに「個人情報を販売または共有しない」リンクを表示する必要があります。このフィールドは openConfirmationDialog と組み合わせて使用する必要があります。また、「米国の州規制」のメッセージ機能で独自のカスタム「販売、共有しない」リンクを使用できるのは、アド マネージャーのみです。
例:
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.ccpa = window.googlefc.ccpa || {};
// Signals that the default DNS link will be overridden.
googlefc.ccpa.overrideDnsLink = true;
</script>
メソッド: 説明と例
googlefc.getConsentStatus(): {number}
googlefc.getConsentedProviderIds(): {!Array<string>}
- 呼び出されると、常に空のリストが返されるようになりました。
googlefc.showRevocationMessage(): {undefined}
現在の EU 規制の同意レコード(存在する場合)を消去し、EU 規制のメッセージを再度表示して、ユーザーが同意に関する決定を変更できるようにします。
例 1: クリックすると取り消しメッセージが表示されるリンクを設定する簡単な例:
<a href="javascript:window.googlefc.showRevocationMessage();">Privacy and cookie settings</a>
<a href="javascript:window.googlefc.showRevocationMessage();" style="display: none;" id="revocation-link">Privacy and cookie settings</a>
<script>
window.googlefc = window.googlefc || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
window.googlefc.callbackQueue.push({
'CONSENT_API_READY':
() => {
// Update the revocation link so that it shows on the page.
const revocationLink = document.getElementById('revocation-link');
revocationLink.style.display = 'block';
}
});
</script>
例 2: 現在のユーザーに EU 規制が適用される場合にのみリンクを表示するには、TCF API で googlefc コールバック キューを使用して、gdprApplies 値が決定されたら、その値に基づいてボタンの表示を条件付きで更新します。この場合は、CONSENT_API_READY API キーを使用します。
<a href="javascript:window.googlefc.showRevocationMessage();" style="display: none;" id="revocation-link">Privacy and cookie settings</a>
<script>
window.googlefc = window.googlefc || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
window.googlefc.callbackQueue.push({
'CONSENT_API_READY':
// Specifying "0" for the version parameter will result in the API call
// using the latest version of the TCF spec.
() => __tcfapi('addEventListener', 0, (tcdata, success) => {
const revocationLink = document.getElementById('revocation-link');
if (!success || !tcdata) {
// Something went wrong, don't show the revocation link.
revocationLink.style.display = 'none';
}
else if (tcdata.gdprApplies) {
revocationLink.style.display = 'block';
} else {
// GDPR does not apply so don't show the revocation link.
revocationLink.style.display = 'none';
}
})
});
</script>
googlefc.getAdBlockerStatus(): {number}
ユーザーの広告ブロック ステータスに応じて、AdBlockerStatusEnum の値を返します。この関数に指定する必要があるキーは AD_BLOCK_DATA_READY です。
例:
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.usstatesoptout = window.googlefc.usstatesoptout || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Queue the callback on the callbackQueue.
googlefc.callbackQueue.push({
'AD_BLOCK_DATA_READY':
() => {
switch (googlefc.getAdBlockerStatus()) {
case googlefc.AdBlockerStatusEnum.EXTENSION_LEVEL_AD_BLOCKER:
case googlefc.AdBlockerStatusEnum.NETWORK_LEVEL_AD_BLOCKER:
// Insert handling for cases where the user is blocking ads.
break;
case googlefc.AdBlockerStatusEnum.NO_AD_BLOCKER:
// Insert handling for cases where the user is not blocking ads.
break;
case googlefc.AdBlockerStatusEnum.UNKNOWN:
// Insert handling for unknown cases.
break;
}
}
});
</script>
googlefc.getAllowAdsStatus(): {number}
ユーザーの広告許可ステータスに応じて、AllowAdsStatusEnum の値を返します。この関数に指定する必要があるキーは AD_BLOCK_DATA_READY です。
例:
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.usstatesoptout = window.googlefc.usstatesoptout || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Queue the callback on the callbackQueue.
googlefc.callbackQueue.push({
'AD_BLOCK_DATA_READY':
() => {
switch (googlefc.getAllowAdsStatus()) {
case googlefc.AllowAdsStatusEnum.ADS_NOT_ALLOWED:
// Insert handling for cases where the user has not allowed ads.
// The user may have never been an ad blocker.
break;
case googlefc.AllowAdsStatusEnum.ADS_ALLOWED:
// Insert handling for cases where the user saw the ad blocking
// message and allowed ads on the site.
break;
case googlefc.AllowAdsStatusEnum.UNKNOWN:
// Insert handling for unknown cases.
break;
}
}
});
</script>
googlefc.usstatesoptout.getInitialUsStatesOptOutStatus(): {number}
ユーザーの米国の州規制のオプトアウト ステータスに応じて、InitialUsStatesOptOutStatusEnum の値を返します。この関数に指定する必要があるキーは INITIAL_US_STATES_OPT_OUT_DATA_READY です。なお、米国の州規制データのその後のリクエストは、GPP API(__gpp)を直接呼び出して取得する必要があります。
[個人情報を販売または共有しない] リンクをオーバーライドする場合は、このメソッドを使用して、サイトにリンクを含めるタイミングを決定できます。
例:
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.usstatesoptout = window.googlefc.usstatesoptout || {}
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Queue the callback on the callbackQueue.
googlefc.callbackQueue.push({
'INITIAL_US_STATES_OPT_OUT_DATA_READY':
() => {
switch (googlefc.usstatesoptout.getInitialUsStatesOptOutStatus()) {
case googlefc.usstatesoptout.InitialUsStatesOptOutStatusEnum.DOES_NOT_APPLY:
// Insert handling for cases where no US state regulation applies to
// the user.
break;
case googlefc.usstatesoptout.InitialUsStatesOptOutStatusEnum.NOT_OPTED_OUT:
// Insert handling for cases where a US state regulation applies to
// the user, and the user has not opted out.
break;
case googlefc.usstatesoptout.InitialUsStatesOptOutStatusEnum.OPTED_OUT:
// Insert handling for cases where a US state regulation applies to the
// user, and the user has opted out.
break;
}
}
});
</script>
googlefc.usstatesoptout.openConfirmationDialog(function(boolean)): {undefined}
デフォルトの「個人情報を販売しない」リンクがオーバーライドされている場合、米国の州規制のオプトアウト確認ダイアログを開きます。ユーザーが確認ダイアログを操作すると、ユーザーがオプトアウトすることを選択した場合は true、それ以外の場合は false を指定して、指定されたコールバック関数が呼び出されます。
例:
<script>
// This callback will be called with the user's US state regulation opt-out
// decision.
const usStateRegCompletionCallback = (userOptedOut) => {
// Insert handling for user opt-out status here.
}
// Invoke the US state regulations confirmation dialog when the user clicks the
// link.
document.getElementById("your-custom-do-not-sell-link").addEventListener(
"click", () => googlefc.usstatesoptout.openConfirmationDialog(usStateRegCompletionCallback));
</script>
googlefc.getGoogleConsentModeValues(): {!Object}
ユーザーの同意の決定に基づいて、各同意モードの目的の現在の値を含む googlefc.GoogleFcConsentModeUserStatus オブジェクトを返します。
想定される使用方法については、EU 規制の同意モードをサポートする Google の同意管理ソリューションの使用をご覧ください。
googlefc.ccpa.getInitialCcpaStatus(): {number}
ユーザーの米国の州規制のオプトアウト ステータスに応じて、InitialCcpaStatusEnum の値を返します。この関数に指定する必要があるキーは INITIAL_CCPA_DATA_READY です。米国の州規制データのその後のリクエストは、GPP API(__gpp)を直接呼び出して取得する必要があります。
例:
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.ccpa = window.googlefc.ccpa || {}
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Queue the callback on the callbackQueue.
googlefc.callbackQueue.push({
'INITIAL_CCPA_DATA_READY':
() => {
switch (googlefc.ccpa.getInitialCcpaStatus()) {
case googlefc.ccpa.InitialCcpaStatusEnum.CCPA_DOES_NOT_APPLY:
// Insert handling for cases where no US state regulation applies to
// the user.
break;
case googlefc.ccpa.InitialCcpaStatusEnum.NOT_OPTED_OUT:
// Insert handling for cases where a US state regulation applies to
// the user, and the user has not opted out.
break;
case googlefc.ccpa.InitialCcpaStatusEnum.OPTED_OUT:
// Insert handling for cases where a US state regulation applies to the
// user, and the user has opted out.
break;
}
}
});
</script>
googlefc.ccpa.openConfirmationDialog(function(boolean)): {undefined}
デフォルトの「個人情報を販売しない」リンクがオーバーライドされている場合、米国の州規制のオプトアウト確認ダイアログを開きます。ユーザーが確認ダイアログを操作すると、ユーザーがオプトアウトすることを選択した場合は true、それ以外の場合は false を指定して、提供されたコールバック関数が呼び出されます。
例:
<script>
// This callback will be called with the user's US state regulation opt-out
// decision.
const usStateRegCompletionCallback = (userOptedOut) => {
// Insert handling for user opt-out status here.
}
// Invoke the US state regulations confirmation dialog when the user clicks the
// link.
document.getElementById("your-custom-ccpa-do-not-sell-link").addEventListener(
"click", () => googlefc.ccpa.openConfirmationDialog(ccpaCompletionCallback));
</script>
GDPR 向けに IAB TCF v2 で Google の同意管理ソリューションを使用する
Google の同意管理ソリューションを使用して IAB TCF v2 フレームワークに準拠した GDPR 同意を収集している場合は、IAB TCF v2 API を使用する必要があります。
CONSENT_API_READY コールバック キューキーを使用すると、対応するコールバックが、IAB TCF v2 API がページで定義されている場合にのみ呼び出されるようにすることができます。これは、IAB TCF v2 API の 'addEventListener' コマンドと組み合わせて使用する必要があります。
例:
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Queue the callback using the CONSENT_API_READY key on the callbackQueue.
window.googlefc.callbackQueue.push({
'CONSENT_API_READY':
() => __tcfapi('addEventListener', 2.2, (data, success) => {
// Do something with consent data value; this callback may be invoked
// multiple times as user completes consent flow.
})
});
</script>
CONSENT_DATA_READY
コールバック キューキーを使用すると、ユーザーの同意が収集され、IAB TCF v2 API を使用してアクセスできる場合にのみ、対応するコールバックが呼び出されるようにすることができます。これは 'addEventListener' コマンドと組み合わせて使用できます。指定したコールバックの最初の呼び出しで提供されるデータには、ユーザーの同意の選択が含まれます(TCF v2 がこのユーザーに適用される場合)。なお、TCF v2.2 のリリースに伴い、'getTCData' コマンドは非推奨になりました。
例:
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Queue the callback using the CONSENT_DATA_READY key on the callbackQueue.
window.googlefc.callbackQueue.push({
'CONSENT_DATA_READY':
() => __tcfapi('addEventListener', 2.2, (data, success) => {
// Do something with consent data value; this callback may be invoked
// multiple times if user consent selections change.
})
});
</script>
EU 規制に対応した同意モードをサポートする Google の同意管理ソリューションを使用する
Google の同意管理ソリューションは、Google 同意モードに関するユーザーの EU 規制の同意の選択を解釈できます(詳しくは、ヘルプセンターをご覧ください)。
同意モードは、Google 広告とアナリティクスのドキュメントに記載されているように、基本モードまたは詳細モードで実装できます。法的要件を満たすためにどの同意モードを実装すべきかについては、法務部門にご相談ください。
高度な同意モードはデフォルトでサポートされています。[プライバシーとメッセージ] の管理画面で同意モードを有効にすると、追加の作業は必要ありません。
Google の同意管理ソリューションを使用して基本の同意モードを実装するには、CONSENT_MODE_DATA_READY コールバック キューキーを使用して、同意モードデータが利用可能になった時点で Google 広告タグと Google アナリティクス タグを条件付きで読み込みます。同意モードのデータは、ファンディング チョイスが同意モードをこのリクエストに適用しないと判断した後(たとえば、EU 規制がこのリクエストに適用されないため)、またはユーザーが EU 規制の同意を決定した後に利用可能になります。同意モードが利用可能になったときにタグを読み込むかどうかを判断する基準については、法務部門に相談してください。
たとえば、エンドユーザーの同意の決定に関係なく、同意モードのデータが利用可能になったらタグを読み込むには、次のようにします。
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Helper function to load Google Ads/Analytics tags once consent mode data is
// ready.
const loadGtagScript = () => {
// Load gtag.js script - code taken from
// https://developers.google.com/tag-platform/security/guides/consent?consentmode=basic#set_up_consent_mode
var gtagScript = document.createElement('script');
gtagScript.async = true;
gtagScript.src = 'https://www.googletagmanager.com/gtag/js?id=<Google tag ID>';
var firstScript = document.getElementsByTagName('script')[0];
firstScript.parentNode.insertBefore(gtagScript,firstScript);
}
// Queue the callback using the CONSENT_MODE_DATA_READY key on the callbackQueue.
window.googlefc.callbackQueue.push({
'CONSENT_MODE_DATA_READY':
() => {
loadGtagScript();
},
});
</script>
googlefc.getGoogleConsentModeValues() API を使用して、同意モードのデータが利用可能な場合に、個々の同意モードの目的の値を取得することもできます。この API は、サポートされている同意モードの目的ごとに 1 つのフィールドを含む GoogleFcConsentModeUserStatus オブジェクトを返します。各フィールドの値は、その同意モードの目的の値を示す列挙値です。
たとえば、googlefc.getGoogleConsentModeValues() を使用して、次のいずれかの場合にのみ Google 広告タグとアナリティクス タグのブロックを解除できます。
- エンドユーザーが EU 規制に関する同意に対しての判断を行い、その結果、すべての同意モードの目的について同意が付与される。または
- すべての同意モードの目的が現在のリクエストに適用されない(EU 規制が適用されない場合や、プライバシーとメッセージで 1 つ以上の目的で同意モードが設定されていない場合に発生する可能性があります)。
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Helper function to determine whether Google Ads and Analytics tags can be
// unblocked. Returns true if all consent mode purposes are set to GRANTED,
// NOT_APPLICABLE, or NOT_CONFIGURED.
const shouldUnblockConsentTags = (googleFcConsentModeStatus) => {
const allConsentModeValues = [
googleFcConsentModeStatus.adStoragePurposeConsentStatus,
googleFcConsentModeStatus.adUserDataPurposeConsentStatus,
googleFcConsentModeStatus.adPersonalizationPurposeConsentStatus,
googleFcConsentModeStatus.analyticsStoragePurposeConsentStatus
];
for (const consentModeValue of allConsentModeValues) {
switch (consentModeValue) {
case googlefc.ConsentModePurposeStatusEnum.CONSENT_MODE_PURPOSE_STATUS_UNKNOWN:
// Indicates either an error case or that consent mode data is not
// ready yet. Cannot unblock tags until consent data is ready and valid,
// so return false.
return false;
case googlefc.ConsentModePurposeStatusEnum.CONSENT_MODE_PURPOSE_STATUS_GRANTED:
// Consent is granted for this consent mode purpose.
break;
case googlefc.ConsentModePurposeStatusEnum.CONSENT_MODE_PURPOSE_STATUS_DENIED:
// Consent is denied for this consent mode purpose. Do not unblock tags.
return false;
case googlefc.ConsentModePurposeStatusEnum.CONSENT_MODE_PURPOSE_STATUS_NOT_APPLICABLE:
// Consent mode does not apply for this purpose.
break;
case googlefc.ConsentModePurposeStatusEnum.CONSENT_MODE_PURPOSE_STATUS_NOT_CONFIGURED:
// Consent mode not configured for this purpose.
// If you configured support for Ads purposes but not Analytics purposes in the
// Privacy & messaging UI, the value of `analyticsStoragePurposeConsentStatus` will
// always be set to NOT_CONFIGURED. If you do not enable any Consent Mode support
// in the Privacy & messaging UI, the values of all purposes will always be set to
// NOT_CONFIGURED.
break;
default:
console.log("Unexpected consent mode value encountered");
}
}
// If all prior checks pass, all consent mode values are either GRANTED,
// NOT_APPLICABLE, or NOT_CONFIGURED.
return true;
};
// Helper function to load Google Ads/Analytics tags.
const loadGtagScript = () => {
// Load gtag.js script - code taken from
// https://developers.google.com/tag-platform/security/guides/consent?consentmode=basic#set_up_consent_mode
var gtagScript = document.createElement('script');
gtagScript.async = true;
gtagScript.src = 'https://www.googletagmanager.com/gtag/js?id=<Google tag ID>';
var firstScript = document.getElementsByTagName('script')[0];
firstScript.parentNode.insertBefore(gtagScript,firstScript);
}
googlefc.callbackQueue.push({
CONSENT_MODE_DATA_READY: () => {
if (shouldUnblockConsentTags(googlefc.getGoogleConsentModeValues())) {
loadGtagScript();
}
},
});
</script>
米国の州規制に対応するために IAB GPP フレームワークで Google の同意管理ソリューションを使用する
Google の同意管理ソリューションを使用して、IAB GPP フレームワークに基づいて米国の州規制のオプトアウト メッセージをエンドユーザーに提供している場合は、IAB GPP API を使用する必要があります。
米国の州規制のオプトアウトの性質上、CONSENT_API_READY または CONSENT_DATA_READY コールバック キューキーを使用して、コールバックが呼び出されたときに IAB GPP API が呼び出し可能で、同意済みのデータを返すようにできます。
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.usstatesoptout = window.googlefc.usstatesoptout || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Queue the callback on the callbackQueue.
window.googlefc.callbackQueue.push({
'CONSENT_DATA_READY':
() => __gpp('ping', (data, success) => {
// Do something with consent data value.
})
});
</script>
米国の州規制に対応する IAB GPP フレームワークで Google の同意管理ソリューションを使用し、独自のカスタム「販売、共有しない」リンクを使用する
Google の同意管理ソリューションを使用して、IAB GPP フレームワークに基づいて米国の州規制のオプトアウト メッセージをエンドユーザーに提供している場合は、googlefc.usstatesoptout.overrideDnsLink フラグを true に設定することで、独自のカスタム「個人情報を販売または共有しない」リンクを提供できます。
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.usstatesoptout = window.googlefc.usstatesoptout || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Signals that the default DNS link will be overridden.
window.googlefc.usstatesoptout.overrideDnsLink = true;
// Register the callback for the initial US state regulations data.
window.googlefc.callbackQueue.push({
'INITIAL_US_STATES_OPT_OUT_DATA_READY': () => {
if (googlefc.usstatesoptout.getInitialUsStatesOptOutStatus() ===
googlefc.usstatesoptout.InitialUsStatesOptOutStatusEnum.NOT_OPTED_OUT) {
// TODO: Display custom Do Not Sell or Share link here.
}
}
});
</script>
これにより、デフォルトの「個人情報の販売または共有を拒否する」リンクが表示されなくなります。次に、米国の州規制のオプトアウト確認ダイアログを呼び出して、カスタムの「販売、共有しない」リンクに対するユーザー操作を処理する必要があります。
独自のカスタム「販売、共有しない」リンクを使用する場合は、リンクが米国の州規制に準拠していることを確認する責任があります。また、「米国の州規制」メッセージ機能で独自のカスタム「販売、共有しない」リンクを使用できるのは、アド マネージャーのみです。
<script>
// This callback will be called when the user makes a US state regulations
// decision.
const usStateRegCompletionCallback = (userOptedOut) => {
if (userOptedOut) {
// TODO: Hide custom Do Not Sell or Share link here.
}
}
// Invoke the US state regulations opt-out confirmation dialog when the user
// clicks the link.
document.getElementById("your-custom-do-not-sell-link").addEventListener(
"click", () => googlefc.usstatesoptout.openConfirmationDialog(usStateRegCompletionCallback));
</script>