> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rev.iq/llms.txt
> Use this file to discover all available pages before exploring further.

# setUid

> 타겟팅을 위한 사용자 ID(uid) 제공. 가변 인자.

export const domain = (() => {
  const placeholder = "your-domain.com";
  if (typeof window !== "undefined" && !globalThis.__revDomainSetup) {
    globalThis.__revDomainSetup = true;
    function textNodes(node) {
      if (node.nodeType === Node.TEXT_NODE) return [node];
      const nodes = [];
      for (const child of node.childNodes) {
        nodes.push(...textNodes(child));
      }
      return nodes;
    }
    function anchorNodes(node) {
      if (node.nodeType === Node.ELEMENT_NODE && node.tagName === "A") return [node];
      const nodes = [];
      for (const child of node.childNodes) {
        nodes.push(...anchorNodes(child));
      }
      return nodes;
    }
    const domain = globalThis.__revDomain || new URLSearchParams(globalThis.location.search).get('domain') || "yourdomain.com";
    globalThis.__revDomain = domain;
    if (globalThis.__revDomainObs) return;
    const obs = globalThis.__revDomainObs || new MutationObserver(mutations => {
      for (const {addedNodes, removedNodes, target} of mutations) {
        for (const node of [...addedNodes, target]) {
          if (node instanceof HTMLScriptElement) continue;
          if (node instanceof HTMLStyleElement) continue;
          for (const textNode of textNodes(node)) {
            if (textNode.nodeValue && textNode.nodeValue.includes(placeholder)) {
              setTimeout(() => {
                textNode.nodeValue = textNode.nodeValue.replace(placeholder, domain);
              }, 100);
            }
          }
          for (const anchorNode of anchorNodes(node)) {
            if (anchorNode.href && anchorNode.href.includes(placeholder)) {
              setTimeout(() => {
                anchorNode.href = anchorNode.href.replace(placeholder, domain);
              }, 100);
            }
          }
        }
      }
    });
    obs.observe(document.body, {
      childList: true,
      subtree: true
    });
  }
  return placeholder;
})();

UID를 제공하면 광고 성과가 크게 향상됩니다. 선택 사항이지만 강력히 권장됩니다.

당사는 모든 개인정보 보호 규정을 준수하며 사용자 식별 가능 데이터를 저장하지 않습니다.
RevIQ에 전달된 UID는 정규화된 후 해시 처리되며, 원본 값은 저장되지 않습니다.

<Check>
  사용자가 추적을 거부한 경우 UID는 저장되거나 전송되지 않습니다.
  따라서 사용자의 추적 설정에 관계없이 이 함수를 안전하게 호출할 수 있습니다.
</Check>

<ParamField path="value" type="Uid" required>
  ```ts theme={null}
  type Uid = {
    u?: string; // 사용자 이름
    e?: string; // 이메일
    p?: string; // 전화번호
  };
  ```
</ParamField>

<CodeGroup>
  ```js 이메일로 설정 theme={null}
  const user = { email: "hachi@rev.iq" };
  reviq.setUid({ e: user.email });
  ```

  ```js 전화번호로 설정 theme={null}
  // 가능하면 국가 코드를 포함하세요
  const user = { phone: "+1 555-555-5555" }; 
  reviq.setUid({ p: user.phone }); 
  ```

  ```js 사용자 이름으로 설정 theme={null}
  const user = { username: "hachi" };
  reviq.setUid({ u: user.username });
  ```
</CodeGroup>
