Movatterモバイル変換


[0]ホーム

URL:


  1. 開発者向けのウェブ技術
  2. Web API
  3. XMLHttpRequest
  4. setAttributionReporting()

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docsコミュニティーについてもっと知り、仲間になるにはこちらから。

View in EnglishAlways switch to English

XMLHttpRequest: setAttributionReporting() メソッド

安全なコンテキスト用: この機能は一部またはすべての対応しているブラウザーにおいて、安全なコンテキスト (HTTPS) でのみ利用できます。

Experimental:これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。

setAttributionReporting()XMLHttpRequest インターフェイスのメソッドで、このリクエストのレスポンスに対して、 JavaScript ベースの帰属ソースまたは帰属トリガーを登録できるようにしたいことを示します。

詳しくは帰属レポート APIを参照してください。

構文

js
setAttributionReporting(options)

引数

options

帰属レポートのオプションを提示するオブジェクトで、次のプロパティが含まれます。

eventSourceEligible

論理値。true に設定すると、このリクエストのレスポンスは、帰属ソースを登録する対象となります。false に設定すると、対象外となります。

triggerEligible

論理値。true に設定すると、このリクエストのレスポンスは、帰属トリガーを登録する対象となります。false に設定すると、対象外となります。

返値

なし (undefined)。

例外

InvalidStateErrorDOMException

関連付けられたXMLHttpRequest開かれるための処理がまだ行われていない場合、またはすでに送信済みである場合に発生します。

TypeErrorDOMException

帰属レポート API の使用が、attribution-reportingPermissions-Policy によってブロックされている場合に発生します。

js
const attributionReporting = {  eventSourceEligible: true,  triggerEligible: false,};function triggerSourceInteraction() {  const req = new XMLHttpRequest();  req.open("GET", "https://shop.example/endpoint");  // 呼び出す前に setAttributionReporting() が使用できることを確認する  if (typeof req.setAttributionReporting === "function") {    req.setAttributionReporting(attributionReporting);    req.send();  } else {    throw new Error("Attribution reporting not available");    // 適切なリカバリーコードをここに入れる  }}// 操作トリガーを、コードに意味のある要素やイベントと関連付けるelem.addEventListener("click", triggerSourceInteraction);

仕様書

Specification
Attribution Reporting
# dom-xmlhttprequest-setattributionreporting

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp