> For the complete documentation index, see [llms.txt](https://doc.batch.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.batch.com/developer/sdk/web/advanced/manage-domains.md).

# Domains and subdomains management

The Web Push standard ties each opt-in to the subdomain on which it was collected: users who opt in to push notifications on `domain.com` are not automatically opted in on `shop.domain.com`. This page explains why, and describes three architectures you can choose from depending on whether your subdomains share a single userbase and purpose or not.

## Why is opt-in bound to a single subdomain?

With Web Push, the push token and the notification permission are bound to the exact subdomain where they were collected. The browser treats each subdomain as a separate installation, with its own opt-in request. As a result, an opt-in on one subdomain does not carry over to another.

This is a constraint of the Web Push standard itself, not a Batch limitation, so it applies regardless of how you configure your project. The standard does not allow cross-domain or cross-subdomain subscriptions. Two consequences follow from it:

* A separate opt-in request appears on each subdomain where you deploy the Batch SDK.
* If users accept the opt-in on two subdomains linked to the same project, a full-base campaign reaches these users twice.

The recommended architecture depends on whether your subdomains belong to the same product and audience, or to distinct ones.

## Case 1: Subdomains of the same product, shared userbase and purpose

This is the most common case. Examples include country sites served on several domains (`domain.fr`, `domain.it`, `us.domain.com`) or several sections of the same product.

Recommended architecture:

* A single project on the Batch dashboard.
* One main subdomain referenced on the project, for example, the one with the most traffic.
* The other subdomains added under **Settings > Channels > Push > Push Configuration: Web >** [**Allowed Origins**](https://doc.batch.com/developer/sdk/web/testing-integration#allowed-origins).
* The Service Worker (`batchsdk-worker-loader.js`) hosted at the root of each subdomain.
* The same JavaScript tag on every subdomain.

For targeting:

* To target the users of one specific subdomain, plan a dedicated custom attribute in your tagging plan, for example `domain_visited = "fr"`.
* An opt-in request appears on each subdomain. If users accept the request on two subdomains and you send a full-base campaign, these users receive the push twice.

## Case 2: Subdomains with distinct userbases and purposes

Examples include a corporate site alongside an e-commerce site, two sister brands on separate subdomains, or two independent products.

Recommended architecture:

* One project per subdomain, each with its own userbase.
* The Service Worker hosted on each subdomain.
* A different JavaScript tag on each subdomain.

With this setup, a separate opt-in request appears on each subdomain, and you target users of a given subdomain through their own project.

## Case 3: One main domain, opt-in collected on a single subdomain, deeplinks to the others

Use this when you want to collect push opt-ins only on one subdomain, for example the home page, while still routing notification clicks to a secondary store subdomain.

Recommended architecture:

* A single project linked to a single subdomain.
* The Service Worker and the JavaScript tag deployed only on the subdomain where opt-in is collected and data is reported.

Deeplinks inside the notifications can still send users to any subdomain. Opt-in collection and click destination are independent.

## Related resources

{% hint style="info" %}

* [Web SDK prerequisites](https://doc.batch.com/developer/sdk/web/getting-started/prerequisites)
* [Custom User ID](https://doc.batch.com/developer/sdk/web/profile-data/custom-user-id)
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://doc.batch.com/developer/sdk/web/advanced/manage-domains.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
