Matomo load-balancing and Tag Manager: missing feature or missing documentation?

As described in the FAQ, I prepared Matomo for load-balancing: 2 “front” machines with tracker and one “UI” machine for the users.
But when the users started to use the tag manager, I figured out that the additional code (in js directory) is generated only on the UI machine, so it was not accessible from the “outside world”.
This means either these files need to become generated on the other machines as well (in that case it’s a missing feature) or the FAQ needs to become extended and state that the “container*js” files need to be synced to the other machines, too (this would be missing documentation).

For others that may find their way here with similar problems:

To use TagManager in an environment with multiple instances, the generated files (for example container_DSGaLFOj.js container_DSGaLFOj_stage_c1dd27d744ee0a632e9dc57e.js container_DSGaLFOj_test_74d339e8493effcffa4e020f.js) must be made available on all instances. In Alecanders scenario above, the files are only available on the UI machine, not the 2 “front” machines.

This problem can be solved by storing the generated files (container_*) on a shared volume (persistent volume in kubernetes in my case). All instances of Matomo/TagManager (UI and both “front” machines) should mount a shared volume in a particular location (for example /opt/bitnami/matomo/js/tag-manager).

You then need to apply a custom configuration to TagManager by modifying the file plugins/TagManager/config/config.php to look something like this:

<?php
return array(
    'TagManagerContainerStorageDir' => function () {
        // the location where we store the generated javascript or json container files
        return '/js/tag-manager'; // <-- Custom
    },
    ...
);
1 Like