> For the complete documentation index, see [llms.txt](https://docs.hackle.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hackle.io/event-management/properties/campaign-properties.md). Agents can also search and read this documentation through its [MCP server](https://docs.hackle.io/~gitbook/mcp).

# 캠페인 속성 (UTM)

Hackle Web SDK는 사용자가 어떤 마케팅 캠페인을 통해 유입되었는지 자동으로 수집해 **사용자 속성**으로 저장합니다. 캠페인 속성은 목적에 따라 세 가지로 나뉩니다.

<table><thead><tr><th width="161.48046875">구분</th><th>속성명</th><th>의미</th></tr></thead><tbody><tr><td><strong>Initial (최초)</strong></td><td><code>initial_utm_source</code>, <code>initial_utm_medium</code>, ...</td><td>이 브라우저에서 <strong>처음</strong> 유입되었을 때의 UTM. 이후 바뀌지 않음</td></tr><tr><td><strong>Last (마지막)</strong></td><td><code>last_utm_source</code>, <code>last_utm_medium</code>, ...</td><td>UTM이 붙은 링크로 <strong>가장 최근에</strong> 유입되었을 때의 UTM</td></tr><tr><td><strong>Current (현재)</strong></td><td><code>utm_source</code>, <code>utm_medium</code>, ... , <code>gclid</code>, <code>fbclid</code></td><td><strong>지금 방문</strong>의 유입 캠페인. UTM 없이 외부·직접 유입되면 초기화됨</td></tr></tbody></table>

{% hint style="info" %}
사용 가능한 SDK 버전

<table><thead><tr><th width="149.9609375">SDK</th><th width="274.6171875">Current (utm_*)</th><th>Initial · Last (initial_utm_*, last_utm_*)</th></tr></thead><tbody><tr><td><code>javascript-sdk</code></td><td>11.18.0+</td><td>12.2.1+</td></tr><tr><td><code>react-sdk</code></td><td>11.18.0+</td><td>12.2.1+</td></tr></tbody></table>
{% endhint %}

## 수집되는 파라미터 <a href="#collected-parameters" id="collected-parameters"></a>

SDK는 페이지 URL의 쿼리 스트링에서 아래 파라미터를 자동으로 읽어들입니다.

<table><thead><tr><th width="152.13671875">구분</th><th width="420.48046875">파라미터</th><th>Initial · Last 수집 여부</th></tr></thead><tbody><tr><td>UTM</td><td><code>utm_source</code>, <code>utm_medium</code>, <code>utm_campaign</code>, <code>utm_term</code>, <code>utm_content</code>, <code>utm_id</code></td><td>O</td></tr><tr><td>광고 클릭 ID</td><td><code>gclid</code> (Google Ads), <code>fbclid</code> (Meta/Facebook)</td><td>X (Current만 수집)</td></tr></tbody></table>

{% hint style="warning" %}

* 값이 **빈 문자열인 파라미터는 무시**됩니다. (예: `?utm_source=` 는 수집되지 않음)
* 새로운 캠페인이 감지되면 사용자 속성이 갱신되고 유입 이벤트가 함께 발생합니다.
  {% endhint %}

## UTM 속성

아래는 UTM 속성 별 동작 비교입니다.

<table><thead><tr><th width="345.17578125">항목</th><th>Initial (initial_utm_*)</th><th>Last (last_utm_*)</th><th>Current (utm_*)</th></tr></thead><tbody><tr><td>값이 기록되는 시점</td><td>이 브라우저의 <strong>첫 세션에서 1회</strong></td><td>UTM 파라미터가 <strong>하나 이상 있는</strong> 링크로 유입될 때</td><td>재평가 시 새 캠페인으로 판정될 때</td></tr><tr><td>새로운 UTM 링크로 재유입</td><td>변경 없음</td><td><strong>덮어쓰기</strong></td><td><strong>덮어쓰기</strong></td></tr><tr><td>UTM 없이 외부 사이트에서 유입 / 주소 직접 입력</td><td>변경 없음</td><td><strong>유지</strong></td><td><strong>초기화</strong> (값 삭제)</td></tr><tr><td>외부 결제·로그인 후 복귀 (UTM 없음)</td><td>변경 없음</td><td><strong>유지</strong></td><td><strong>초기화</strong> (값 삭제)</td></tr><tr><td>사이트 내부 이동 (같은 도메인, UTM 없음)</td><td>변경 없음</td><td>유지</td><td>유지</td></tr><tr><td>일부 UTM 파라미터만 있는 링크로 유입</td><td>링크에 없는 파라미터는 <code>"EMPTY"</code>로 기록 (첫 세션인 경우)</td><td>링크에 있는 파라미터는 덮어쓰고 <strong>없는 파라미터는 값 삭제</strong></td><td>링크에 있는 파라미터는 덮어쓰고 없는 파라미터는 값 삭제</td></tr><tr><td>첫 방문에 UTM이 없음 (직접 유입 등)</td><td>모든 파라미터를 <code>"EMPTY"</code>로 기록</td><td>값 없음</td><td>값 없음</td></tr><tr><td>이미 값이 있는 경우</td><td><strong>덮어쓰지 않음</strong> (서버에서 1회만 기록)</td><td>덮어씀</td><td>덮어씀</td></tr><tr><td><p><strong>타겟팅</strong></p><p>로컬 평가 (<code>evaluationMode: "local"</code>)</p></td><td><mark style="color:red;"><strong>사용 불가</strong></mark></td><td>사용 가능</td><td>사용 가능</td></tr><tr><td><strong>타겟팅</strong><br>원격 평가 (<code>evaluationMode: "remote"</code>)</td><td>사용 가능</td><td>사용 가능</td><td>사용 가능</td></tr></tbody></table>

{% hint style="danger" %}
**로컬 평가(`evaluationMode: "local"`)에서는 `initial_utm_*` 속성으로 타겟팅할 수 없습니다.**

`initial_utm_*` 속성은 SDK가 핵클 서버로만 전송하며, SDK가 들고 있는 사용자 속성(userProperties)에는 포함되지 않습니다.

그래서 A/B 테스트, 기능 플래그, 원격 구성, 인앱 메시지의 타겟팅은 평가 방식에 따라 동작이 다릅니다.

* **로컬 평가**: SDK가 디바이스에 저장된 사용자 속성으로 직접 평가합니다.\
  이 사용자 속성에 `initial_utm_*`가 없으므로 **타겟팅 조건에 `initial_utm_*`를 사용해도 동작하지 않습니다.**
* **원격 평가:** 핵클 서버에 저장된 사용자 속성으로 평가하므로 `initial_utm_*` 속성으로 타겟팅할 수 있습니다.

로컬 평가에서 유입 캠페인 기준으로 타겟팅해야 한다면 `last_utm_*` 또는 `utm_*` 속성을 사용하세요. 평가 방식에 대한 자세한 내용은 [평가 방식](https://docs.hackle.io/development-guide/sdk/evaluation-mode.md) 문서를 참고하세요.
{% endhint %}

### Initial 속성 상세

`initial_utm_*` 속성은 사용자가 이 브라우저에서 처음 유입된 캠페인을 기록합니다.

* **기록 시점**: SDK가 이 브라우저에 캠페인 정보를 처음 저장하는 시점(첫 세션)에 한 번만 기록됩니다. 캠페인 정보는 루트 도메인 기준 쿠키에 저장되므로 서브도메인 간에도 공유됩니다.
* **덮어쓰지 않음**: 핵클 서버에 이미 `initial_utm_*` 값이 저장된 사용자라면 기존 값이 유지됩니다.
* **`"EMPTY"` 값**: 첫 유입 시점에 없던 UTM 파라미터는 `"EMPTY"`로 기록됩니다. 예를 들어 UTM 없이 직접 방문한 사용자는 `initial_utm_source`가 `"EMPTY"`입니다. 분석할 때 `"EMPTY"`는 "첫 유입에 해당 UTM이 없었음"으로 해석하세요.
* **로컬 평가에서 타겟팅 불가**: SDK가 들고 있는 사용자 속성에 포함되지 않으므로, 로컬 평가에서는 A/B 테스트, 기능 플래그, 원격 구성, 인앱 메시지의 타겟팅 조건으로 사용할 수 없습니다. 원격 평가(`evaluationMode: "remote"`)에서는 핵클 서버에 저장된 사용자 속성으로 평가하므로 타겟팅에 사용할 수 있습니다.

{% hint style="warning" %}
**SDK 12.2.1 적용 이전에 방문한 사용자**

이미 캠페인 정보가 저장된 브라우저(SDK 11.18.0 이상이 적용된 사이트에 방문한 적이 있는 브라우저)에서는 `initial_utm_*` 속성이 기록되지 않습니다. `initial_utm_*` 속성은 SDK 12.2.1 적용 이후 **처음 방문한 브라우저부터** 수집됩니다.

반대로 쿠키를 삭제했거나, 다른 브라우저·시크릿 모드로 방문한 경우에는 첫 방문으로 판단됩니다.
{% endhint %}

### Last 속성 상세

`last_utm_*` 속성은 UTM이 붙은 링크로 가장 최근에 유입된 캠페인을 기록합니다.

* **UTM이 있을 때만 갱신**: UTM 파라미터가 하나 이상 있는 링크로 유입될 때만 갱신됩니다. UTM 없는 방문(직접 입력, 북마크, 외부 결제·로그인 후 복귀 등)에서는 값이 그대로 유지됩니다.
* **한 묶음으로 갱신**: 갱신될 때 이번 링크에 있는 파라미터는 새 값으로 덮어쓰고, 없는 파라미터는 값을 삭제합니다.
* **광고 클릭 ID만 있는 유입**: `gclid`, `fbclid`만 있고 UTM이 없는 유입에서는 갱신되지 않습니다.

{% hint style="info" %}
기존 `utm_*` 속성은 외부 결제(PG)나 소셜 로그인(OAuth)을 다녀오면 초기화되는 한계가 있었습니다.

`last_utm_*` 속성은 이런 경우에도 유지되므로, **전환 직전의 마케팅 캠페인을 분석할 때는 `last_utm_*` 속성을 사용**하는 것을 권장합니다.
{% endhint %}

### Current 속성 상세

`utm_*`, `gclid`, `fbclid` 속성은 현재 방문의 유입 캠페인을 나타냅니다.

### 갱신되는 시점 (재평가) <a href="#refresh-timing" id="refresh-timing"></a>

SDK는 아래 두 시점에 현재 URL을 다시 확인하여 캠페인 속성을 갱신할지 판단합니다.\
Initial, Last 속성도 같은 시점에 함께 판단됩니다.

1. **페이지가 새로 로드될 때**\
   최초 진입, 새로고침, 서버 왕복이 있는 페이지 전환 등 SDK가 다시 초기화되는 경우 재평가가 실행됩니다.
2. **새로운 세션이 시작될 때**\
   아래 조건 중 하나에서 재평가가 실행됩니다.
   * 사용자 식별자(userId)가 변경됨 (예: 로그인/로그아웃)
   * 세션 타임아웃(기본 **30분**의 비활동) 이후 새 이벤트가 발생함

{% hint style="info" %}
새로고침이 없는 SPA(Single Page Application)의 클라이언트 사이드 라우팅만으로는 재평가가 발생하지 않습니다. 최초 진입 이후 라우팅 과정에서만 나타난 UTM 파라미터는 다음 페이지 로드나 새 세션이 시작될 때 수집됩니다.
{% endhint %}

#### 유지 · 갱신 · 초기화 판정 규칙 <a href="#keep-update-reset-rules" id="keep-update-reset-rules"></a>

재평가 시 SDK는 **현재 페이지 URL의 캠페인 값**과 **직전 페이지(리퍼러)의 도메인**을 함께 보고 다음과 같이 판단합니다.

<table><thead><tr><th width="231.71484375">현재 URL 상태</th><th width="281.1171875">유입 경로</th><th width="122.69921875">Current 동작</th><th width="110.9609375">Last 동작</th></tr></thead><tbody><tr><td>UTM <strong>있음</strong>, 이전 저장값과 다름</td><td>무관</td><td><strong>갱신</strong></td><td><strong>갱신</strong></td></tr><tr><td>UTM <strong>있음</strong>, 이전 저장값과 동일</td><td>무관</td><td>유지</td><td>유지</td></tr><tr><td>UTM <strong>없음</strong></td><td><strong>같은 도메인 내 이동</strong><br>(직전 페이지가 우리 사이트)</td><td>유지</td><td>유지</td></tr><tr><td>UTM <strong>없음</strong></td><td><strong>외부 사이트에서 유입</strong> 또는 <strong>리퍼러 없음</strong>(주소 직접 입력·북마크)</td><td><strong>초기화</strong></td><td>유지</td></tr></tbody></table>


---

# 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.hackle.io/event-management/properties/campaign-properties.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.
