> ## 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>
