split the display of in apps on two different sites

  • 26 October 2023
  • 4 replies

We have the main webstite name  A and a one more website B with our learning materials.
depending on our customers data in our Customer IO  Workspace, we want to show different in-apps on both websites.
i assume that because i have to use  YOUR_SITE_ID inside JS tag to make in apps work. 

t.setAttribute('data-site-id', 'YOUR_SITE_ID');

that is bound to a workspace, there could be no way to split in-apps, depending on the webstie we want to show, and they will appear on both websites.
Could you please confirm my assumptions that it is not possible, or suggest a solution. 

4 replies

Userlevel 2

Hey @eldar99 


You can use a different data-site-id value depending on the website, the specific web app will send data to using whichever Site ID you provide at the time the snippet is initialized. 


We can’t get into all of the details of how to go about doing this — given the many libraries and frameworks people use to build and run their web apps — but hopefully the following pseudocode example helps you visualize this:

<script type="text/javascript">
+ var whichWebApp = webAppBeingVisited == "a" ? "a" : "b";
var _cio = _cio || [];
(function() {
var a,b,c;a=function(f){return function(){_cio.push([f].
var t = document.createElement('script'),
s = document.getElementsByTagName('script')[0];
t.async = true; = 'cio-tracker';
- t.setAttribute('data-site-id', 'YOUR_SITE_ID');
+ t.setAttribute('data-site-id', whichWebApp == "a" ? siteIdA : siteIdB);
t.setAttribute('data-use-array-params', 'true');

//Enables in-app messaging
t.setAttribute('data-use-in-app', 'true');

t.src = '';
//If your account is in the EU, use:
//t.src = ''
s.parentNode.insertBefore(t, s);


The above example borrows from the snippet shown here:


The pseudocode above uses a conditional (ternary) operator and assumes that you have these variables already established in the global scope:

  • webAppBeingVisited: some variable where you’ve established which web app is being visited. In this case, I’m using “a” and “b” as values to conditionally apply a specific Site ID value. 
  • siteIdA: the Site ID you want to use for web app “A” 
  • siteIdB: the Site ID you want to use for web app “B” 


Let us know if you have other questions about this. 😊

hI @Jordan , thanks for response.
Imagine i have created 2 different site ids within the same production workspace.

and injected siteIdA to the first website and siteIdB to the second via JS tag you provided.

The question is how to configure a Campaign within Production workspace, to send in app messages only to SiteA or SiteB.

Userlevel 2

So those two Api keys you highlighted are for the same workspace. There is no way to send or prevent sending an in-app message based on the Site ID value.


Your in-app messages from the Production workspace will send to either of those two keys you setup, the two API keys “Production” and “Production workspace” will interact with your Production workspace environment. Any message queued from that workspace can be read by either web app.


What it sounds like you need to setup are “page rules”:


You can use one API Key (one Site ID across both sites) but only show your message if they access a page matching a specific URL. E.g. One page rule could show your message if the URL contains and another page rule could show your message if the URL contains


Does that make sense?

i will update you if it works