# Custom collector URL

Load the Screeb tag and send its requests through a proxy on your own domain, so ad blockers stop blocking surveys and messages.

Ad blockers often block the default Screeb addresses (`t.screeb.app`, `rpc.screeb.app`). On the Enterprise plan, with the Custom domains feature enabled, you can route Screeb through a reverse proxy on your own domain, such as `analytics.acme.com`.

It takes three steps:

1. Run a reverse proxy on your domain that forwards each path to the matching Screeb service, see [Reverse proxy templates](https://developers.screeb.app/sdk-js/reverse-proxy-templates).
2. Have an admin add your domains to the allowed domains of the workspace, see [Serve Screeb through your own domain](https://help.screeb.app/account/custom-domains/).
3. Load the tag from the proxy and point its endpoints at the proxy, as below.

## Configure the tag

Set `window.ScreebConfig.endpoints` before the tag loads, and load `tag.js` from your proxy:

```html
<script>
  window.ScreebConfig = {
    endpoints: {
      rpc: "https://analytics.acme.com/rpc",
      static: "https://analytics.acme.com/static",
      report: "https://analytics.acme.com/report",
      hostedPage: "https://analytics.acme.com/hosted-page",
    },
  };

  (function(s,c,r,ee,b){
    s.ScreebObject=r;
    if(typeof s[r]!="function")s[r]=function(){var d=arguments;return new Promise(function(o,k){(s[r].q=s[r].q||[]).push({v:1,args:d,ok:o,ko:k})})};
    b=c.createElement("script");b.id=r;b.src=ee;c.head.appendChild(b);
  })(window,document,"$screeb","https://analytics.acme.com/tag.js");

  $screeb("init", "<YOUR-CHANNEL-ID>");
</script>
```

The endpoints are read from `window.ScreebConfig`, not from the `init` options: an `endpoints` object passed to `init` is ignored.

The tag finds its own address from the `src` of the loader script (the element with `id="$screeb"`). It keeps the origin only and loads its bundles from `<origin>/v<version>/`, so your proxy must serve `tag.js` and the `/v...` paths at the root of its host. The path of `src` is not kept: a loader served from `/sdk/tag.js` still fetches its bundles from `/v<version>/`.

| Key          | Default                      | Used for                                                             |
| ------------ | ---------------------------- | -------------------------------------------------------------------- |
| `rpc`        | `https://rpc.screeb.app/rpc` | REST API: configuration, identity, tracking, answers, session replay |
| `static`     | `https://static.screeb.app`  | Images, audio and video attached to your questions                   |
| `report`     | `https://r.screeb.app/rpc`   | SDK error and health reporting                                       |
| `hostedPage` | `https://survey.screeb.app`  | Hosted survey pages                                                  |

You only override the endpoints you proxy: the others keep their default. Emoji (`https://emoji.screeb.app`) and file uploads (`https://s3.fr-par.scw.cloud`) always use their Screeb address.

If your site enforces a Content Security Policy, set `window.ScreebConfig` in a script file of your own rather than inline, and allow your proxy origin where the policy allows Screeb, see [CSP, iframes and security requirements](https://developers.screeb.app/sdk-js/security-requirements).

## Allowed domains

Once the workspace has at least one allowed domain, the API answers only the pages whose `Origin` header matches the list, and rejects the others with `403` (`origin not in workspace allowed domains`). So the list must hold every domain your site is served from, staging and preview included, not only the proxy:

- A wildcard such as `*.acme.com` covers every subdomain at any depth, but not `acme.com` itself.
- `localhost`, `127.0.0.1` and `::1` are always accepted.
- Add the proxy hostname too: when it starts, the tag checks the custom endpoints against the list and logs a console warning for each one that is missing.

## Security notes

- Every custom endpoint must use HTTPS. The tag refuses a loader served over plain HTTP, and browsers block HTTP requests from an HTTPS page.
- API requests carry no cookies and no credentials when the proxy is on another origin than your page.
- The proxy must forward the browser's `Origin` header unchanged: the allowed domains check reads it.
