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

> Provide a user ID (uid) for targeting. Variadic.

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;
})();

Providing a UID significantly improves ad performance. As such, it is
optional, but highly recommended.

We comply with all privacy regulations and do not store any user-identifiable
data. Once passed to RevIQ, the UID is normalized and then hashed; we never
store the original value.

<Check>
  If the user has opted out of tracking, the UID will not be stored or
  transmitted. Thus it is safe to call this function regardless of the user's
  tracking preferences.
</Check>

<ParamField path="value" type="Uid" required>
  ```ts theme={null}
  type Uid = {
    u?: string; // username
    e?: string; // email
    p?: string; // phone
  };
  ```
</ParamField>

<CodeGroup>
  ```js With email theme={null}
  const user = { email: "hachi@rev.iq" };
  reviq.setUid({ e: user.email });
  ```

  ```js With phone theme={null}
  // include country code if possible
  const user = { phone: "+1 555-555-5555" }; 
  reviq.setUid({ p: user.phone }); 
  ```

  ```js With username theme={null}
  const user = { username: "hachi" };
  reviq.setUid({ u: user.username });
  ```
</CodeGroup>
