# How to migrate multiple websites into Batch Omnichannel projects?

As part of the [migration from the Batch MEP to the CEP](https://doc.batch.com/getting-started/other/implementation-guides/how-to-get-ready-to-migrate-from-the-batch-mep-to-the-cep), your mobile apps and websites need to be grouped into **omnichannel projects**. Since each omnichannel project can contain a maximum of **1** Android app, **1** iOS app, and **1** website, you may wonder how to configure your dashboard with multiple websites.

Here is how to set up the Batch dashboard depending on your websites' typology:

## Case A: Independent websites

This case applies when you manage websites that correspond to <mark style="background-color:$info;">**different products**</mark> (e.g., separate brands or media titles) via separate environments on the Batch MEP dashboard.

👉 In this case, simply request that our team create <mark style="background-color:$success;">**one omnichannel project per website**</mark>. If there are corresponding mobile apps, they can be included in the respective projects.

## Case B: Variants of the same website

This case applies if you manage websites for the <mark style="background-color:$info;">**same product**</mark> via separate environments on the Batch MEP dashboard due to a difference in subdomains. The most common case corresponds to country sites managed on different domains (e.g., domain.fr, domain.it, domain.es, etc.).

👉 In this case, we will group all web domains within <mark style="background-color:$success;">**a single web environment**</mark>, which we will call the **target environment**.

To do so, follow these steps:

{% stepper %}
{% step %}

### **Pre-requisite: Unique Custom User IDs**

* [ ] First, ensure that <mark style="background-color:yellow;">**the same Custom User ID**</mark> <mark style="background-color:yellow;"></mark><mark style="background-color:yellow;">is used across the websites</mark> you plan to group. If not, the ID will need to be changed in the JavaScript tag (see [step 3](#javascript-tag-implementation)).
  {% endstep %}

{% step %}

### **Managing web environments (Batch dashboard)**

* [ ] <mark style="background-color:yellow;">Choose between these</mark> <mark style="background-color:yellow;"></mark><mark style="background-color:yellow;">**2 options**</mark> to define the target environment:\
  \
  1\. <mark style="background-color:$info;">**Keep an existing web environment**</mark>\
  Advantage: You can continue addressing a large portion of your opt-in base without interruption if the selected website contains most of the users.\
  \
  2\. <mark style="background-color:$info;">**or Create a new environment (Recommended)**</mark>\
  Advantage: Greater flexibility for migrating campaigns.\
  •  You can recreate campaigns as drafts on the new environment and switch over at the right time, instead of having to update all live campaigns.\
  •  This allows better handling of languages, regions, and translations.\
  •  This option is also preferable if a change of Custom User ID is required (e.g., when your web and app environments do not share the same Custom User ID).

#### Option 1 steps:

* [ ] <mark style="background-color:yellow;">Select the website environment</mark> that you want to use as the target environment (e.g., domain.fr).
* [ ] <mark style="background-color:yellow;">Add the secondary domains</mark> (e.g., domain.de, domain.it...) under Settings > Push settings > **Allowed origins**:

<figure><img src="/files/S0pn6Tp0oTua0w6I4Tik" alt="" width="563"><figcaption></figcaption></figure>

#### Option 2 steps:

* [ ] <mark style="background-color:yellow;">Create the target environment</mark> by adding a new website to your Batch dashboard (from the left bar, "Add a new app or website).

<figure><img src="/files/6Jzvk7jOuUP2hCpi9PK6" alt="" width="148"><figcaption></figcaption></figure>

* [ ] <mark style="background-color:yellow;">Declare one of your domains</mark> (e.g., domain.fr) as the primary domain on this new environment:

<figure><img src="/files/XAOZIH9xWCdSZkrmKShO" alt="" width="375"><figcaption></figcaption></figure>

* [ ] <mark style="background-color:yellow;">Add the secondary domains</mark> (e.g., domain.de, domain.it...) under Settings > Push settings > **Allowed origins**:

<figure><img src="/files/S0pn6Tp0oTua0w6I4Tik" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="info" %}
At this stage, your Batch contact can already **create the omnichannel project** including the target web environment and the corresponding mobile apps (if there are any).
{% endhint %}
{% endstep %}

{% step %}

### **JavaScript tag implementation**

**Update the Batch JavaScript tag** on all your websites:

* [ ] <mark style="background-color:$info;">If your Custom User ID differs between the websites of the project</mark>: Update the method to set the [Custom User ID](/developer/sdk/web/profile-data/custom-user-id.md) with the necessary variable.
* [ ] <mark style="background-color:yellow;">Replace the</mark> <mark style="background-color:yellow;"></mark><mark style="background-color:yellow;">**SDK API Key**</mark><mark style="background-color:yellow;">,</mark> <mark style="background-color:yellow;"></mark><mark style="background-color:yellow;">**Auth Key**</mark><mark style="background-color:yellow;">, and</mark> <mark style="background-color:yellow;"></mark><mark style="background-color:yellow;">**VAPID public key**</mark><mark style="background-color:yellow;">.</mark> These keys can be found under Settings > General and Settings > Push settings of the target environment.
* [ ] <mark style="background-color:yellow;">Modify the</mark> [<mark style="background-color:yellow;">**scope**</mark> <mark style="background-color:yellow;"></mark><mark style="background-color:yellow;">of the Batch Service Worker</mark>](https://doc.batch.com/developer/sdk/web/advanced/declare-path-service-worker#registering-a-service-worker-in-a-sub-scope) (e.g., turn it to `/js/`) on each domain.
* [ ] <mark style="background-color:yellow;">Unregister the</mark> <mark style="background-color:yellow;"></mark><mark style="background-color:yellow;">**Service Worker**</mark> from the previous scope by adapting the script below to each domain (only required for secondary domains if option 1 was chosen).

```javascript
async function replaceBatchRegistrations() {
  if (!("serviceWorker" in navigator)) {
    return;
  }

  // List registered service workers
  const currentServiceWorkerRegistrations = await navigator.serviceWorker.getRegistrations();
  await currentServiceWorkerRegistrations.forEach( async (registration) => {
    if (registration.scope === 'https://www.domain.fr/') { //REPLACE WITH OLD SCOPE
      // Found old service worker -> Removing
      console.debug("Found old service worker -> Removing")
      await registration.unregister()
    } else if (registration.scope === 'https://www.domain.fr/js/') { //REPLACE WITH NEW SCOPE
      if (!("pushManager" in registration)) {
        return;
      }
   
    }
  })
}
await replaceBatchRegistrations()
```

{% endstep %}

{% step %}

### **Managing orchestrations**

* [ ] <mark style="background-color:yellow;">Duplicate your existing Web Push automations</mark> as drafts in the new environment.
* [ ] \[Optional] Send campaigns from the old environments, encouraging users to revisit the site - this helps accelerate the migration of your user base.
* [ ] Once a sufficient volume of users has migrated to the target environment:
  * <mark style="background-color:yellow;">Deactivate</mark> the automations on the **old** environment.
  * <mark style="background-color:yellow;">Activate</mark> the automations on the **target** environment.
    {% endstep %}
    {% endstepper %}


---

# Agent Instructions: 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:

```
GET https://doc.batch.com/getting-started/other/implementation-guides/mep-to-cep-migration/how-to-migrate-multiple-websites-into-batch-omnichannel-projects.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
