Firing an event for only one site ID

I was implementing multiple sites in a single container; like this: Multiple PiwikPro sites under a single container

Adding it this way is fine but I couldn’t find specific example in the documentation about what to do if I want to send an event or a page view to a single site ID only. As example, let’s say I wanted to set a custom dimension for only one of the site ids. The following script seems to work for me. Is this the correct approach?

<script>
	setTimeout(function() {
        _ppas.push(["setTrackerUrl", "https://examplesite.piwik.pro/ppms.php"]);
        _ppas.push(["setSiteId", "8b645e9f-f842-4f42-a986-abc123456789"]);
        _ppas.push(["setCustomDimensionValue", 1, "loginStatus"]);
  		_ppas.push(['setCustomUrl', {{ Page Url }}]);
  		_ppas.push(['setDocumentTitle', {{ Global - Document Title }}]);
 		_ppas.push(['trackPageView']);
	}, 1000);
</script>

Hi onderval!

I think it would be best to check the site ID this way:

_ppas.push([function () {
  if (this.getSiteId() === '8b645e9f-f842-4f42-a986-abc123456789') {
      this.setCustomDimensionValue(1, "loginStatus");
      }
 }])

Please let me know whether this works for you :slight_smile:.