Skip to content

SharedID Edge for hosting companies ​

This guide is for a company that serves many publishers' sites from its own platform: a managed WordPress or news-site host on Cloudflare for SaaS, a platform built on Workers for Platforms, or a host with its own CDN account (CloudFront, Fastly, Akamai, Vercel, your own nginx). You already answer on each publisher's hostname, so you can run SharedID Edge for every hosted site, with nothing for the publisher to change but their Prebid.js configuration.

If you don't host the sites, but run one endpoint that each publisher's CDN forwards /_sid/* to, read SharedID Edge for upstream operators instead. If you do both, host some publishers and run an endpoint for others on their own CDNs, you'll use both guides: this one for the sites you serve, that one for the rest. One deployment can be both (see FAQ).

Contents ​

Why it has to be the site's own hostname ​

SharedID Edge sets the Prebid.js SharedID cookie (_pubcid) from the server, so Safari and other browsers keep it for up to 400 days instead of the 7 days they allow cookies written by script. Safari grants that only to a first-party server-set cookie:

  • Same hostname family: the response must come from the site's own domain (www.publisher.example/_sid/sync), not yours. A third-party domain's cookies aren't the site's at all.
  • Same IP addresses: since Safari 16.4, a cookie set by a server whose IP address doesn't match the site's is capped at 7 days. So a CNAME from sid.publisher.example to a server of yours doesn't work either (Safari's CNAME-cloaking defence caps those too).

A hosting company is in the best position to meet both: the /_sid/* path on the publisher's hostname, answered by the same edge that serves the pages. That's a route, a behaviour or a rule on the platform you already run, not a new hostname. verify-deployment checks both conditions (Verifying).

Choosing a deployment ​

You serve sites withDeployPer-site settingsSees the site's hostname?Notes
Cloudflare for SaaS (custom hostnames on your zone)One Worker on your SaaS zone's */_sid/* routeCustom hostname metadata (no redeploy per site) or SID_HOSTSYesRecommended. Cloudflare: Hosting companies
Cloudflare for SaaS + Workers for PlatformsOne Worker per publisher in a trusted dispatch namespace, picked by a dispatch WorkerEach Worker's own varsYesPer-publisher isolation and versions; a paid add-on; more to deploy. Same section.
Cloudflare, with publishers on their own zonesA Worker in each publisher's accountEach Worker's varsYesThat's the upstream-operator model A: Upstream operators
Amazon CloudFront (one distribution with many alternate domain names)The Lambda function as a /_sid/* behaviourSID_HOSTS (Lambda's 4 KB environment limit applies)Only if a CloudFront Function sets X-Forwarded-Host from Host (below)AWS Lambda
Fastly (one service, many domains)The Compute service, by Request RoutingSID_HOSTS in the config store (8,000 characters a value)Yes, with Request Routing (not yet confirmed on a live service)Fastly
Akamai (one property, many hostnames)The EdgeWorker on a /_sid/* rulePMUSER_SID_HOSTS, or a child rule per hostnameYesAkamai: per site
Vercel (a multi-tenant project with many domains)The route handler or middlewareSID_HOSTSYesVercel
Google Cloud (an external Application Load Balancer)The Cloud Run function, by a URL map path ruleSID_HOSTSThe Host the load balancer passes; check per hostnameGoogle Cloud
Azure Front DoorThe function app, by a Front Door routeOne function app per siteNo: the function sees its own *.azurewebsites.net hostAzure; see FAQ
Your own nginx, HAProxy or ingressThe Node.js server behind itSID_HOSTSYes, from the Host your proxy passesNode.js

How to choose:

  • On Cloudflare for SaaS, use one shared Worker with custom hostname metadata. Adding a site is an API call on the custom hostname you create anyway. Use SID_HOSTS in the Worker's vars instead until your Cloudflare account team enables metadata, or if you have few sites. Use Workers for Platforms if you already run it, or need per-publisher versions, modules or rollouts.
  • Not a Cloudflare Snippet: Snippets are per zone and limited in number, their configuration is fixed at build time, they can't read custom hostname metadata, and whether snippet rules run for SaaS custom hostnames is untested (#105).
  • Elsewhere, put SharedID Edge on the platform that serves the pages, with SID_HOSTS. Where that platform's configuration is too small for your list of sites (the table in How many sites fit), split the sites over several deployments, by hostname.
  • Never a deployment on a hostname of your own that the publisher CNAMEs to, or a workers.dev, cloudfront.net or vercel.app URL: those aren't the site's hostname and IP addresses.

One deployment for many sites ​

SID_HOSTS gives each site the settings that differ, on top of the deployment's own (Several sites from one deployment). With SID_COOKIE_DOMAIN=auto for the deployment (recommended, below), most sites need no settings of their own:

json
{
  "www.pub-a.example": {},
  "pub-a.example": {},
  "www.pub-b.example": { "SID_MODULES": "geo" },
  "www.pub-c.example": { "SID_COOKIE_DOMAIN": "pub-c.example" }
}

Here pub-c.example is on a Prebid.js older than 11.53.0, so its domain is set by hand.

The essentials:

  • The request's hostname picks the site, lower-cased, without the port. List every hostname a site answers on (www. and the bare domain).
  • A hostname that isn't listed gets a 404 and no cookies, as if SharedID Edge weren't there. So the deployment can sit on a wildcard route (*/_sid/*) for all your hosted sites, and only those you've onboarded get SharedID Edge. "SID_HOSTS": "{}" gives that with no sites listed, for a Cloudflare deployment whose sites all come from custom hostname metadata.
  • Validated at start-up: a mistake in one site's settings fails the whole deployment (every site gets a 500), naming the hostname. Check a change before deploying it (Deploying changes). Custom hostname metadata is the exception: invalid metadata fails only that site's requests.
  • What can't vary per site: SID_BASE_PATH, SID_MODULE_SECRETS (the ec passphrase, say) and the modules built into the deployment. SID_MODULES per site chooses among those built in.
  • The deployment must see the site's hostname. The Cloudflare Worker, Vercel, Akamai, Fastly with Request Routing and the Node.js server behind a proxy that passes Host do. Check any other with a request to /_sid/v1 on each hostname: a 404 means the deployment sees another host.

Cloudflare for SaaS custom hostname metadata ​

With metadata (enabled by your Cloudflare account team, on subdomain-style custom hostnames), each site's settings live on its custom hostname under a sharedid key, and the Worker's vars have "SID_HOSTS": "{}":

sh
curl -X PATCH "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/custom_hostnames/$HOSTNAME_ID" \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" -H "Content-Type: application/json" \
  --data '{"custom_metadata": {"sharedid": {"SID_COOKIE_DOMAIN": "pub-a.example"}}}'

It reaches the Worker within about 30 seconds. An entry in SID_HOSTS takes precedence over a hostname's metadata. Workers for Platforms, the dispatch Worker, and why the dispatch namespace must be trusted (or the Worker gets no request.cf, and so no visitor country for GDPR) are in the Cloudflare adapter's Hosting companies section, with every command.

If a publisher's own zone is on Cloudflare too (their proxied hostname is a CNAME to yours, "orange-to-orange"), their zone handles the request first: a /_sid/* route of theirs answers instead of yours. Agree with them who runs it.

Orange-to-orange with a Worker on one side and a Snippet on the other ​

A tempting split is the publisher keeping their own Worker for their site while your zone answers /_sid/* with a Snippet, which costs nothing extra on a paid plan. Treat it with scepticism:

  • A publisher Worker only blocks your zone from answering when it terminates the request locally. If it handles /_sid/* itself without forwarding, your zone's Snippet won't see the request. A route matching /_sid/* (or a catch-all route) does not by itself prevent the Worker from forwarding the request with fetch(request); that forwarded request can continue to the SaaS zone. The publisher can either forward the request or leave /_sid/* out of its Worker routes. SharedID Edge itself answers its /_sid/* routes and does not forward them.
  • Whether a Snippet runs for custom-hostname traffic at all is untested. Cloudflare's Snippets documentation doesn't cover Cloudflare for SaaS custom hostnames, let alone traffic that has already passed through the publisher's zone. Until it's been checked on a live zone (#105), don't plan on it.
  • A Snippet can't read custom hostname metadata, so every site has to be in SID_HOSTS in the Snippet's 32 KB. That caps it at a few hundred sites before any code, so a large host is back to a Worker anyway (How many sites fit).
  • Two accounts' rules, caching and firewall settings apply to the same request, which is harder to reason about and to debug, and a Snippet has no logs or versions to help.
  • The visitor's location: in orange-to-orange your zone should see the visitor, not the publisher's zone, in request.cf. That's what GDPR by country needs, but it hasn't been verified live either (#135).

If the publisher wants to keep their own Worker, the simplest arrangement is a Worker on your side too, or SharedID Edge running in the publisher's zone (Model A in the upstream-operator guide). Orange-to-orange is best avoided where the publisher's DNS can simply point at you without being proxied.

Amazon CloudFront and Lambda ​

Behind CloudFront, the function is called on its function URL's hostname, signed with origin access control, so it can't see the visitor's Host. It takes the site from X-Forwarded-Host, which CloudFront doesn't add itself, and which the AllViewerExceptHostHeader policy passes on as the visitor sent it. So with SID_HOSTS, associate a CloudFront Function with the /_sid/* behaviour, on viewer request, that sets it from the Host the visitor connected to:

js
function handler(event) {
  var request = event.request;
  request.headers['x-forwarded-host'] = { value: request.headers.host.value };
  return request;
}

The rest of the behaviour is as in Add the behaviour to an existing distribution. This follows CloudFront's documentation and hasn't been run on a live distribution yet. Check each hostname with /_sid/v1 (a 404 means X-Forwarded-Host is missing or not listed) and verify-deployment.

How many sites fit ​

SID_HOSTS is one setting, so its size is limited by where the platform keeps settings. An entry like "www.pub-a.example":{"SID_COOKIE_DOMAIN":"pub-a.example"}, is about 55 characters; two hostnames per site make about 110.

PlatformLimitAbout how many sites (two hostnames each)
Cloudflare WorkerEach variable's size (Workers limits); custom hostname metadata has no shared limitUse metadata beyond a few dozen
AWS Lambda4 KB for all of a function's environment variables together (Lambda quotas)30
Fastly Compute8,000 characters per config store value70
Akamai EdgeWorkers1,024 characters for all PMUSER_ variables (4,000 on some tiers)Use a child rule per hostname instead
Vercel, Google Cloud, the Node.js serverLarge (tens of kilobytes, or none)Hundreds

These are estimates from the platforms' published limits. Past them, split the sites over several deployments (by hostname, each with its own route or rule), or on Akamai use child rules that set PMUSER_SID_COOKIE_DOMAIN per hostname (The property rule).

Each site needs, at least:

  • SID_COOKIE_DOMAIN: the domain Prebid.js writes _pubcid on, normally the registrable domain (pub-a.example for www.pub-a.example). Get it wrong and the browser ends up with two _pubcid cookies (Configure Prebid.js). host-only for a site whose Prebid.js writes host-only cookies.
    • Recommended: auto, once for the whole deployment. With Prebid.js 11.53.0 or later and pixelCookieDomain: true on the publisher's pages, Prebid.js sends the domain it writes _pubcid on with every sync, and the deployment uses it when it's the site's hostname or a parent of it (else host-only). It's checked against the hostname the request is for, the site's own, which is also what picks the site in SID_HOSTS. See Cookie domain auto.
    • Set it per site for a publisher on an older Prebid.js (its cookies would otherwise be host-only), and for sites that share a parent domain with unrelated sites, such as site-a.yourhost.example and site-b.yourhost.example where yourhost.example isn't on the Public Suffix List: there Prebid.js would report yourhost.example, so give each its own hostname or host-only. A site's own value wins over the deployment's auto.

and may set any other core setting: SID_MODULES (among those built in), SID_MODULE_CONFIG, SID_ALLOWED_ORIGINS (if another of the publisher's origins reads /_sid/v1 from script), SID_VENDOR_ID, SID_SKIP_BOTS, SID_SYNC_CACHE_SECONDS. The Configuration reference lists them.

Consent is decided per request, the same on every site, and needs no per-site work beyond the publisher's CMP (Consent and opt-out):

  • Opt-out, Global Privacy Control (Sec-GPC: 1) and COPPA always delete the ID cookies and set none.
  • TCF: with a TC string, the publisher's own consent (the TC string's publisher segment) decides, by default. The publisher's CMP must ask for publisher consent for Purpose 1 and one of Purposes 2 to 10, and either Prebid.js sends the consent with the sync (pixelConsent: true, Prebid.js 11.53.0 and later; see Configure Prebid.js) or the CMP stores the TC string in the euconsent-v2 cookie, all the sync route sees otherwise. Set SID_VENDOR_ID for a site only if its SharedID is collected under a TCF vendor's consent instead.
  • GDPR without a TC string follows the visitor's country, from your platform's own location data (Cloudflare's request.cf, CloudFront's viewer country, and so on). That's why a Workers for Platforms namespace must be trusted, and why a deployment must not read location from headers a visitor can send.
  • The publisher's privacy page links to https://www.pub-a.example/_sid/optout (and /_sid/optin), on their own hostname.

Who does what: you run the deployment and keep it on the site's hostname; the publisher runs the CMP, the privacy disclosures and the Prebid.js configuration. Agree in your terms that SharedID Edge sets a first-party ID cookie on their domain, and what for.

Onboarding a publisher ​

  1. Collect: every hostname the site answers on, their Prebid.js version (with 11.53.0 or later, auto finds the domain; otherwise, the domain Prebid.js writes _pubcid on: check the cookie's Domain in the browser's developer tools on a page with Prebid.js), whether they use a CMP with TCF, and which modules they want (ip, geo, ua and the rest: Modules).
  2. Add the site's settings:
    • Cloudflare with metadata: PATCH the custom hostname's custom_metadata with {"sharedid": {}}, or {"sharedid": {"SID_COOKIE_DOMAIN": "…"}} when not auto (above); no deploy.
    • Workers for Platforms: deploy a Worker for them into the namespace, and map their hostname to it (Cloudflare).
    • Everywhere else: add their hostnames to SID_HOSTS, check the change (Deploying changes) and deploy.
  3. Make sure /_sid/* reaches the deployment on their hostnames: a wildcard route or behaviour already covers new sites on most platforms; add a route, domain or Request Routing rule where it doesn't.
  4. Verify from outside: npm run verify-deployment -- --site https://www.pub-a.example (Verifying).
  5. Turn it on in Prebid.js on the publisher's pages, or have them do it: sharedIdSystem with pixelUrl: '/_sid/sync', extend: true and pixelCookieDomain: true, and cookie storage named _pubcid (Configure Prebid.js). Until then, nothing changes on their pages.
  6. Tell the publisher the opt-out URL, the debugging headers (Troubleshooting) and what the /_sid/v1 modules return, if they use them.

Offboarding: remove the site's metadata, SID_HOSTS entries or Worker, and deploy. Its /_sid/* then gets a 404 and no cookies. Existing _pubcid cookies stay in browsers and keep working with Prebid.js on its own; ask the publisher to remove pixelUrl, or each page view makes a request that only gets a 404.

Verifying ​

From a checkout of this repository (npm ci once):

sh
npm run verify-deployment -- --site https://www.pub-a.example

It checks, from outside, that /_sid/* answers from the same IP addresses as the site, that /_sid/sync sets _pubcid (Secure, SameSite=Lax, a long lifetime, readable by script) and the HttpOnly recovery copy, that nothing came from a shared cache, and that /_sid/v1 returns its JSON. Then, by hand:

  • The right site's settings: curl -sI 'https://www.pub-a.example/_sid/sync?id=pubcid:test-id' shows Domain=pub-a.example on the cookies.
  • An unlisted hostname gets nothing: /_sid/v1 on a hosted site you haven't onboarded returns 404.
  • The visitor's location reaches it (it decides GDPR): with the geo module on, /_sid/v1 shows your own country in ortb2.device.geo; from a location where GDPR applies (the EU, the rest of the EEA, the UK or Turkey; a VPN will do) without a TC string, /_sid/sync sets no cookie and X-SharedID-Status says why.

Run verify-deployment for every site after onboarding, and for a sample after each update.

Operations ​

Updating SharedID Edge ​

Releases are this repository's tags; read the changes before updating, especially anything about settings. Rebuild and redeploy the one shared deployment. With Workers for Platforms, redeploy each publisher's Worker into the namespace, with a script over your list of publishers, a few first. Then run verify-deployment on a sample of sites.

Deploying changes ​

Because one invalid site fails the deployment, check every SID_HOSTS change before it goes out. Two quick ways:

  • Run the Node.js server locally with the same settings: after npm run build, SID_HOSTS="$(cat sid-hosts.json)" node packages/adapters/node/dist/cli.js refuses to start if anything is wrong, naming the hostname and the setting (Configuration error: SID_HOSTS["www.pub-b.example"]: …).
  • Or deploy to a staging environment first (a Wrangler environment, a second stack or service) and request /_sid/v1 there.

Keep SID_HOSTS in version control, generated from your list of sites, so a change is reviewable and a rollback is a revert.

Monitoring ​

SharedID Edge logs nothing about requests. What you have:

  • The platform's metrics: request counts and status codes for the Worker, function or service. A burst of 500s is a configuration error (the platform's log names the setting and, for SID_HOSTS, the hostname); 404s on /_sid/* are unlisted hostnames, or routes that don't match.
  • The debugging headers on every response: X-SharedID-Source (where the ID came from) and X-SharedID-Status (why no cookie was set), for support requests (Troubleshooting).
  • verify-deployment on a schedule against a few sites, as the project's own live tests do.

Request volume ​

SharedID Edge runs only on its own routes (/_sid/*), never on the site's pages, images or scripts, so a host isn't adding a Worker (or Lambda, or Fastly service) to every request. How many /_sid/* requests reach it per page view depends on the routes the pages call and on what can be cached:

RequestHow often it reaches the endpoint
/_sid/sync (Prebid.js's pixelUrl), visitor with storage allowedThe first visit, then at most about once a day per browser: a successful sync that set an ID is cached privately for SID_SYNC_CACHE_SECONDS (86400 by default), and a response served from the browser's cache never reaches the endpoint. Without extend: true, Prebid.js only calls it when it mints an ID.
/_sid/sync, visitor whose storage is denied (opt-out, GPC, COPPA, or GDPR with no consent)Every page view that calls it: those responses aren't cached (no-store), since the next one must still delete cookies or honour new consent. Where many visitors are in GDPR countries without a CMP that stores the TC string in euconsent-v2 (Consent), expect this to dominate.
/_sid/sync with the clickid module running on itEvery page view: clickid must see each landing page, so it makes the sync no-store. Leave clickid out of SID_SYNC_MODULES (or SID_MODULES) where volume matters more than click IDs.
/_sid/sync with SID_SYNC_CACHE_SECONDS=0Every page view.
/_sid/v1Once per page view that fetches it, only if the pages use modules' output (ip, geo, ua, …). The SharedID itself doesn't need it.
/_sid/optout, /_sid/optinOnly when a visitor uses them.
Bots and crawlersWhatever they request. Most don't run Prebid.js, so they rarely reach /_sid/*; ones that do follow the rows above (SID_SKIP_BOTS stops minting for them, not the request).

So for a site where pages don't fetch /_sid/v1 and clickid is off, the endpoint sees roughly one request per consenting visitor per day plus one per page view of visitors whose storage is denied: far below the site's page views. With /_sid/v1 on every page, add one request per page view.

To size a deployment, count, per site and per day: daily visitors (syncs), page views of visitors without storage consent, and page views that fetch /_sid/v1. The platform's own analytics give the real numbers once it's running: Workers analytics or Logpush on Cloudflare, CloudWatch for Lambda, Fastly's real-time stats.

Cost and abuse ​

Each /_sid/* request is one invocation. With Prebid.js, a browser calls /_sid/sync at most about once a day (the response is cached privately for SID_SYNC_CACHE_SECONDS), plus /_sid/v1 on each page view if your pages fetch the modules' output. So requests are at most about page views plus daily visitors. The platforms' pricing pages give the cost per million requests (Cloudflare Workers, AWS Lambda, Fastly, Vercel); the upstream-operator guide has a worked estimate.

Rate limiting belongs to the platform, in front of the worker, which keeps no state and refuses only oversized requests itself: a WAF rate limiting rule on /_sid/* on Cloudflare, an AWS WAF rate-based rule on the CloudFront behaviour and reserved concurrency on the function, limit_req in nginx. Leave room for real traffic: every page view of a busy site may call /_sid/v1, and many visitors share an address behind a NAT. To keep one site's flood from running up the bill for the rest, count per site too: the Cloudflare Worker's SID_RATE_LIMIT_HOST binding, or a rule keyed on the host. Abuse protection and cost control has the rule for each platform, thresholds, and budget alerts and caps.

What's been verified live ​

The results of each live run are below. How SharedID Edge is verified has the overall picture for every model in Choosing a deployment.

  • Verified: the Cloudflare Worker on an ordinary route, by the project's live tests on every merge (verify-deployment, the conformance suite and unmodified Prebid.js in three browsers).
  • Tested locally: SID_HOSTS (live too, below) by the conformance suite on every adapter; custom hostname metadata by the Worker's unit tests, in workerd; and every adapter against a local stand-in for its platform, or its local runtime.
  • Verified live (November 2026): Cloudflare for SaaS with one shared Worker and SID_HOSTS, with the project's SaaS setup: a free-plan SaaS zone, and custom hostnames whose DNS is on another provider (Route 53), CNAMEd to the fallback origin.
    • The Worker's */_sid/* route on the SaaS zone answers for custom-hostname traffic, from the same Cloudflare addresses as the site, while the zone's own hostnames with more specific routes keep theirs.
    • request.cf is the visitor's: /_sid/v1 with ip and geo shows the visitor's address, country, region and city. Forged X-Forwarded-For, True-Client-IP, CF-IPCountry and X-SID-* headers change nothing (a forged CF-Connecting-IP is refused by Cloudflare itself, error 1000).
    • SID_HOSTS picks the custom hostname's settings (Domain= the publisher's domain); a custom hostname that isn't listed gets a 404 and no cookies.
    • verify-deployment passes, and so does unmodified Prebid.js in Chromium, Firefox and WebKit (42 of 42).
    • Since 17 November 2026, the project's upstream-operator and SaaS live tests redeploy the SaaS Workers from main on every merge, nightly and on demand, and repeat these checks on a listed and an unlisted custom hostname, with verify-deployment and the browser tests (first green run).
    • A route on one custom hostname beats */_sid/*: with the test pages on a saas.publisher.example/* route, /_sid/* never reached SharedID Edge. Serve the pages from your origin or a */* route (Cloudflare: Hosting companies).
  • Not yet verified live: request.cf.isEUCountry and GDPR for a visitor in the EU (the runs came from the US), Workers for Platforms with a trusted namespace, custom hostname metadata reaching the Worker (it needs Cloudflare's account team), and orange-to-orange; #135 has the test plan (#110 the background). Snippets on SaaS zones: #105. The CloudFront Function above and Fastly's Request Routing follow those platforms' documentation.

Run verify-deployment on your first sites before rolling out widely, and tell us what you find in #135.

FAQ ​

Do publishers need to change anything? Only their Prebid.js configuration (pixelUrl: '/_sid/sync'), and their privacy page's opt-out link. Their DNS and site stay as they are.

Can we serve it from our own domain, to keep it simple? No: the cookie must come from the publisher's hostname and IP addresses (why). Safari would cap it at 7 days, the problem SharedID Edge exists to solve.

We host some publishers and run an endpoint for others on their own CDNs. Use this guide for the sites you host and the upstream-operator guide for the rest. One Cloudflare Worker, AWS Lambda function, Fastly service or Node.js server can't do both at once, though: with trusted-upstream mode on, every request must carry the upstream secret, including those from your own SaaS zone. Run two deployments: one on your SaaS zone's route for hosted sites, and one on a hostname of its own, in trusted-upstream mode, for the upstream-operator endpoint.

Do we need a TCF vendor ID? Not usually. SharedID is the publisher's first-party ID, so the default publisher mode reads the publisher's own consent. See Consent and opt-out.

Azure Front Door: why one function app per site? Behind Front Door, the function app sees its own *.azurewebsites.net hostname, not the site's, so SID_HOSTS can't tell the sites apart; the adapter doesn't read Front Door's X-Forwarded-Host. Give each site its own function app and route, or run the Node.js server behind Front Door instead.

Does it work with the WordPress or Drupal plugin our sites use? SharedID Edge replaces the plugins' server-set cookie; see Migrate from the WordPress or Drupal plugin.

What about IP-derived IDs? None by default. Vendor modules such as ec derive one from the client IP, are opt-in at build time, and are disclosed in their READMEs (Modules). If you build one in, decide per site with SID_MODULES.