기여 분석 소스 등록

클릭수 및 조회수를 적절한 이벤트에 기여도 부여하도록 소스를 등록하는 방법을 알아보세요.

기여 분석 소스는 광고 기술이 다음과 같은 종류의 정보를 연결할 수 있는 광고 관련 이벤트 (클릭 또는 조회)입니다.

  • 광고 소재 ID, 캠페인 정보, 지역 등의 문맥 보고 데이터
  • 전환 대상: 사용자가 전환할 것으로 예상되는 사이트입니다.

이 문서의 단계에 따라 소스(광고 노출수 또는 클릭수)를 등록하면 브라우저에서 전환 기여도를 부여할 수 있습니다.

등록 방법

기여 분석 소스를 등록하려면 HTML 요소 또는 JavaScript 호출을 사용하세요.

  • <a> 태그
  • <img> 태그
  • <script> 태그
  • fetch 통화
  • XMLHttpRequest
  • window.open 통화

그러면 소스 등록 HTTP 응답 헤더로 응답하는 네트워크 요청이 생성됩니다.

클릭수 또는 조회수의 소스 등록

클릭 또는 조회 중 하나에 대한 기여 분석 소스를 등록하려면 여기에 설명된 단계를 따르세요. 완료 단계가 이어집니다. 요약하면 다음과 같습니다.

  1. 소스 등록을 시작합니다. HTML 요소 또는 JavaScript 호출을 사용하여 요청합니다. 다음 섹션에서 알 수 있듯이 이 단계는 클릭수와 조회수에 따라 다릅니다.
  2. 소스 등록 헤더로 응답하여 소스 등록을 완료합니다. 이 요청을 수신하면 Attribution-Reporting-Register-Source 헤더로 응답합니다. 이 헤더에서 선택한 Attribution Reporting 구성을 지정합니다. 이 단계는 클릭수와 조회수 모두 동일합니다.

    요약 보고서의 예:

    {
      "aggregation_keys": {
        "campaignCounts": "0x159",
        "geoValue": "0x5"
      },
      "aggregatable_report_window": "86400",
      "destination": "https://example.com"
    }
    

    이벤트 수준 보고서의 예:

    {
      "source_event_id": "12340873456",
      "destination": "[eTLD+1]",
      "expiry": "[64-bit signed integer]",
      "priority": "[64-bit signed integer]",
      "event_report_window": "[64-bit signed integer]"
    }
    

필수 및 선택 속성

HTML 요소를 사용하거나 소스를 등록하기 위해 JavaScript를 호출할 때 attributionsrc 또는 attributionReporting를 사용해야 할 수 있습니다. 이러한 요건이 필요한 경우는 다음 표를 참고하세요.

attributionsrc선택사항인 경우 이를 사용하면 요청에 기여 분석 보고를 적용할 수 있음을 나타냅니다. attributionsrc를 사용하면 브라우저가 Attribution-Reporting-Eligible 헤더를 전송합니다. 앱-웹 측정에 대해서도 유용합니다. attributionsrc가 있으면 브라우저가 Attribution-Reporting-Support 헤더를 전송합니다.

등록 방법 소스
<a> 태그 (탐색 소스)
attributionsrc필수입니다.
<img> 태그 (이벤트 소스)
attributionsrc필수입니다.
<script> 태그 (이벤트 소스)
attributionsrc필수입니다.
fetch 통화 attributionReporting 옵션은 필수입니다.
XMLHttpRequest attributionReporting 옵션은 필수입니다.
window.open 통화 (탐색 소스)
attributionsrc필수입니다.

1단계: 소스 등록 시작

클릭수와 조회수의 경우 1단계가 다릅니다.

클릭에 대한 기여 분석 소스를 등록하려면 <a> 태그 또는 JavaScript window.open()를 사용하면 됩니다.

앵커 사용

노출수 또는 클릭수를 측정하려는 기존 <a> 태그에 attributionsrc를 추가합니다.

<a href="https://shoes.example/..." attributionsrc>Click me</a>

자세한 내용은 예시 코드를 참고하세요.

스크립트 사용

attributionsrcwindow.open()를 호출합니다.

window.open(
  "https://shoes.example/...",
  "_blank",
  "attributionsrc");

이 메서드는 사용자 상호작용 후 5초 이내에 호출되어야 고려됩니다.

attributionsrc를 단독으로 추가하는 대신 이미지나 스크립트에 단일 URL 값을 지정할 수 있습니다.

<a href=... attributionsrc="https://a.example/register-source">Click me</a>

JavaScript의 경우 attributionsrc에 값을 할당하는 경우 매개변수가 부적절하게 파싱되는 원인이 되는 =와 같은 특수 문자가 포함된 경우 URL을 인코딩해야 합니다.

다음과 같이 인코딩합니다.

const encodedUrl = encodeURIComponent(
  "https://adtech.example/attribution_source?ad_id=...");
window.open(
  "https://shoes.example/landing",
   "_blank",
   `attributionsrc=${encodedUrl}`);

attributionsrc는 여기에 <a> 태그로 표시된 것처럼 공백으로 구분된 URL 목록을 사용할 수도 있습니다.

<a href=... attributionsrc="https://a.example/register-source
  https://b.example/register-source">Click me</a>

또는 여기에서 window.open()를 사용하는 것처럼

window.open("...", "_blank", `attributionsrc=${encodedUrl1}
  attributionsrc=${encodedUrl2}`)

이 경우 두 URL 모두 탐색 소스 사용 가능 attributionsrc 요청 (Attribution-Reporting-Eligible 헤더가 포함된 요청)을 수신합니다.

값이 있거나 없는 attributionsrc

앞에서 보았듯이 URL 없이 attributionsrc를 지정할 수 있습니다. 단일 URL을 지정할 수도 있습니다. 또한 공백으로 구분된 URL 목록을 사용할 수 있습니다.

URL을 사용하면 브라우저가 Attribution-Reporting-Eligible 요청 헤더를 포함하는 별도의 연결 유지 가져오기 요청(URL마다 하나씩)을 시작합니다.

이는 요소의 기본 요청과 별개인 요청에 응답하여 소스 등록을 실행하려는 경우에 유용합니다.

예를 들어 앵커 요소의 클릭에 대한 소스를 등록해야 하는 경우 실제로 대상을 제어할 수 없을 수 있습니다. 이 경우 소스 등록 헤더를 탐색과 별개이며 완전히 제어할 수 있는 요청에 대한 응답으로 전송하는 구성을 사용해야 합니다. attributionsrc에 명시적인 값을 지정하면 브라우저에 추가 요청을 실행하고 대상을 구성하도록 지시합니다.

뷰의 기여 분석 소스를 등록하려면 attributionsrc 속성을 추가할 이미지 또는 스크립트 태그를 사용하면 됩니다.

또는 JavaScript fetch() 또는 XMLHttpRequest()를 사용할 수 있습니다.

이미지 포함

<img attributionsrc
src="https://adtech.example/attribution_source?ad_id=...">

스크립트 사용

<script attributionsrc
  src="https://adtech.example/attribution_source?ad_id=..."></script>

원하는 경우 클릭과 동일한 방식으로 attributionsrc의 URL 값을 지정할 수 있습니다. 즉, 이미지 또는 스크립트의 경우 다음과 같이 attributionsrc URL을 설정할 수 있습니다.

단일 URL을 사용하는 경우:

<img attributionsrc="https://adtech.example/attribution_source?ad_id=123">

URL 목록을 사용하면 다음과 같은 작업을 할 수 있습니다.

<img attributionsrc="https://a.example/register-source
  https://b.example/register-source">

fetch() 또는 XMLHttpRequest() 사용

이 코드는 attributionsrc가 있는 HTML 요청이 실행하는 작업을 효과적으로 시뮬레이션합니다.

const attributionReporting = {
  eventSourceEligible: true,
  triggerEligible: false,
};

// Optionally set keepalive to make sure the request outlives the page.
window.fetch("https://adtech.example/attribution_source?my_ad_id=123",
  { keepalive: true, attributionReporting });
const attributionReporting = {
  eventSourceEligible: true,
  triggerEligible: false,
};

const req = new XMLHttpRequest();
req.open("GET", url);
req.setAttributionReporting(attributionReporting);
req.send();

2단계: 헤더 (클릭수 및 조회수)를 사용하여 응답

클릭과 조회 모두의 다음 단계는 Attribution-Reporting-Register-Source 헤더로 응답하는 것입니다.

자세한 내용은 예시 코드를 참고하세요.

서버에서 브라우저 요청을 수신하면 응답하고 응답에 Attribution-Reporting-Register-Source 헤더를 포함합니다.

res.set(
  "Attribution-Reporting-Register-Source",
  JSON.stringify({
    // Use source_event_id to map it to any granular information
    // you need at ad-serving time
    source_event_id: "412444888111012",
    destination: "https://advertiser.example",
    // Optional fields
    expiry: "604800",
    priority: "100",
    debug_key: "122939999"
  })
);

문자열로 변환된 헤더는 다음과 같이 표시됩니다.

{"source_event_id":"412444888111012","destination":"https://advertiser.example","expiry":"604800","priority":"100","debug_key":"122939999"}

다음 단계

기여 분석 트리거를 등록하는 방법을 알아보세요.