Running 2 Piwik Pro Tag Managers on the same website

Yeah, you are correct - there is no way of using the Piwik PRO tracking tag template inside a meta setup. There are some technical limitations when it comes to pulling the site configuration from the Administration module to the meta setup. Maybe it will change in the future.

I think you should be able to add the tracking code in a “less user friendly” way tho. You can pretty much copy and paste the tracking code (Piwik PRO tracking template) from your website’s source code (or the tag manager debugger) and add it to a custom HTML tag in the meta setup. It’s not a perfect solution as some of the settings (e.g. setting the domains, disabling cookies) have to be done in this piece of code by using the _paq API.

It would be also beneficial to change the site UUID based on the current URL or hostname ({{ Site UUID lookup table }} in this example).

<script type="text/javascript">
    var _paq = _paq || [];
    (function () {
        var trackAnonymously = {{ Piwik PRO Anonymization }}('analytics');
        if (trackAnonymously) {
            _paq.push(['setUserIsAnonymous', 1]);
            _paq.push(['disableCookies']);
        }
    }());
</script>
<script type="text/javascript">
    var _paq = _paq || [];
    _paq.push(['setTrackingSource', 'jstc_tm']);
    _paq.push(['setSessionIdStrictPrivacyMode', true]);
    _paq.push(['enableLinkTracking']);
    _paq.push(['setIpTracking', true]);
    _paq.push(['setDomains', ['example.com']]);
    _paq.push(['trackPageView']);
    _paq.push(['enableJSErrorTracking']);
    (function(p,i,w,ik) {
        var g=ik.createElement('script'),s=ik.getElementsByTagName('script')[0];
        _paq.push(['setTrackerUrl', p]);
        _paq.push(['setSiteId', w]);
        g.type='text/javascript';g.async=true;g.defer=true;g.src=i;s.parentNode.insertBefore(g,s);
    })('https://abartczak.piwik.pro/ppms.php','https://abartczak.containers.piwik.pro/ppms.js',{{ Site UUID lookup table }},document)
</script>

You should be able to add a second tracker if needed by calling addTracker.

And this would probably also require having a deanonymization tag which can also be yoinked from the tag manager debugger. That’s because if you turn off the Piwik PRO tracking tag it will also disable the deanonymization one as well.

<script type="text/javascript">
    var _paq = window._paq || [];
    (function () {
        var consents = {{ Consents }};
        var consentType = 'analytics';
        _paq.push(['setVisitorCookieTimeout', 33955200]);
        if (typeof consents !== 'undefined' &&
            consents.hasOwnProperty('current_state') &&
            consents.current_state.hasOwnProperty(consentType) &&
            consents.current_state[consentType] === 1 &&
            consents.hasOwnProperty('previous_state') &&
            consents.previous_state.hasOwnProperty(consentType) &&
            consents.previous_state[consentType] !== 1
        ) {
            _paq.push(['deanonymizeUser']);
        }
    }());
</script>

Some disadvantages of this would be:

  • No access to the tag priority feature
  • Code is less user friendly than UI (imo)
  • Goals added through the meta setup have to be triggered per site (e.g. hostname condition) as a single goal UUID is unique to the Piwik PRO site it was created on.