기여 분석 소스 등록

소스를 등록하여 클릭 및 조회를 적절한 이벤트에 부여하는 방법을 알아봅니다.

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

  • 광고 소재 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선택사항인 경우 이를 사용하면 요청이 Attribution Reporting에 적합함을 나타냅니다. 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>

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

스크립트 사용

attributionsrc번으로 window.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 ensure 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"}

다음 단계

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