Preview uses piwikUrl and doesnt seem overridable

Testing preview uses piwikUrl from database to reference the domain for hosting container_CONTAINERID_preview.js.
In my case this is http(s):// and not http(s)://

piwikUrl is updated by core:archive and visits to matomo dashboard on and they race about updating this field in the db.

Hi @roflmao
What happens in the network (while using the production container AND also the preview one)?
How is configured the MTM bootstrap code: with, or with

It seems it is automatically configured via matomo’s piwikUrl from the database which is automatically set by matomo upon visiting the site and same with running core:archive. Visiting the page gives piwikUrl set to and running the archive updates it do the ip of the container running the core:archive.

Can i set the domain for preview as a variable in Matomo Tag Manager to override?

Hi @roflmao
Very strange behavior…
Does problem occur only in preview mode?
To which address do you configure MTM container ( , or with

Only preview which gives container_ID.js with content:

(function() {
    var b = document;
    var a = window;
    if ((document.cookie.indexOf('mtmPreview1_FDVOG8VX%3D1') !== -1 && window.location.href.indexOf('&mtmPreviewMode=0') === -1 && window.location.href.indexOf('?mtmPreviewMode=0') === -1) || window.location.href.indexOf('&mtmPreviewMode=FDVOG8VX') !== -1 || window.location.href.indexOf('?mtmPreviewMode=FDVOG8VX') !== -1) {

        var d = document
          , g = d.createElement('script')
          , s = d.getElementsByTagName('script')[0];
        g.type = 'text/javascript';
        g.async = false;
        g.defer = false;
        g.src = '';
        s.parentNode.insertBefore(g, s);

The MTM is hosted on

The problem here is g.src is set to a seperate host, not keeping the domain as regular MTM does without preview.

Hi @roflmao
Can you confirm the Matomo version?
This behavior is very strange. Could @innocraft explain this in depth?

This is Matomo 4.15.1