Multiple domains from single CMS

If you use a multisite CMS system like Typo3, Wordpress Multisite or Magento and you do not have the ability to set up scripts for the separate domains you need to modify the embed script if you have multiple domains connected.

Use the following script as an example to setup 3 domains:

JavaScript

var hostname = window.location.hostname;
var script = document.createElement("script");
var apiKey = '';

// use domain.com, without https://

// to get correct value, take the output of window.location.hostname in dev tools on that domain
if (hostname === ' Your Domain A') {
    apiKey = 'Api key of the domain A';

} if (hostname === 'Domain B') {
    apiKey = 'Api key of domain B';   

} else if (hostname === 'Domain C') {
    apiKey = 'Api key of domain C';    
}

script.src="https://consent.cookiefirst.com/sites/" + hostname + "-" + apiKey + "/consent.js";

document.head.appendChild(script);

Also available in