An unexpected website was found in the request: website id was set to '0'

Hi all, encountering a very similar issue with MTM (matomo.cloud)

For some reason, I have a series of sites where the site ID will be determined by a combo of 2 datalayer-based variables, e.g. environment and sitename:

_mtm.push({"environment":"dev","sitename":"corporate"});

My thinking was to first combine both variables using a Custom JavaScript variable for later use in a “lookup table”:

function () {
  var env = "{{DL - Environment}}";
  var site= "{{DL - Sitename}}";

  // Debug fails and returns variable names with curly brackets
  console.log("Environment: " + env);
  console.log("Sitename: " + site);

  var sites = [ // use arrays to act like a lookup table
    "dev|corporate|3",
    "prod|blog|2"
  ];
  for (var i=0; i<sites.length;i++){
    var c = sites[i].split("|");
    if (c[0]==env && c[1]==disp){
      return c[2];
    }
  }
  return 1;
}

Of course the above fails because I can’t access the datalayer variables’ values as variables.

Next I tried using a Custom HTML tag to concatenate environment and sitename and that worked. For a while.

<script>
 var _mtmSite = {{DL - Environment}}+"|" + {{DL - Sitename}};
</script>

Great, now I have a page-level variable I can play with (validated in debug mode) and use as a lookup table variable? Right? Right?
Nope!

Assuming I create a variable using page variable _mtmSite, I can use advanced tag settings to create a lookup table:
if equals dev|corporate then equals 1
if equals dev|blog then equals 2

In theory this is supposed to work but as soon as I reference a variable as site ID in my Matomo Analytics config variable, all I get is the error message:`

Matomo idSite: An unexpected website was found in the request: website id was set to '0' .

Please advise, my only other option is otherwise to create one container per site/app and that kind of defeats my tag management strategy.

Hi,

This issue sounds pretty similar to this one which will be fixed in the next release (3.8.0 which will come out soon)

Thanks Lukas!
Can you confirm this is getting rolled out to cloud customers as well?

Great news! Thanks for getting this into the next release.

Yes, the latest Matomo update will also be rolled out on Cloud shortly after the Open Source release.