Issues with installing Piwik PRO and Matomo on the same site


I also implemented Piwik Pro and Matomo according to option 1 explained here:

See attached screenshot.

However, with the set up, I had no more data about consent and data regarding sessions was no more accurate…

Am I missing anything here?

Our client really insist on having Piwik Pro and Matomo to run at the same time on their website.
Otherwise they will choose to keep Matomo only, which I, as an agency, am not glad about (since I believe Piwik Pro is the best solution for digital marketing and attribution purposes).

Would appreciate a hand on this! :slight_smile:

Thank you in advance for your feedback,
Best regards,


Hi. Thanks for the kind words.

Can you share the website URL? You have to keep in mind, that going with option 1 installs only Piwik PRO Analytics (without Tag Manager and Consent Manager). That’s the reason you don’t see consent stats. If you want to use Piwik PRO to handle consents, we could reorganize the setup a bit:

  • install both Piwik PRO and Matomo via Piwik PRO Tag manager
  • set up both Piwik PRO and Matomo via custom async tags in Tag Manager to avoid namespaces overlap

Adding a comment to the code you pasted. If you want to compare apples with apples, you have to remove the lines deanonymizeUser and setuserIsAnonymous, because I presume those are not available in Matomo

Hey Kuba,

Thanks for your feedback!

Here is the website:

Since we have a campaign running, Matomo was temporarily disabled and we’re running with Piwik Pro only.

I’ll try what you just explain and get back to you if needed!

Thanks for the support :slight_smile:

Hey Kuba,

So I just updated the set up:

  • creating a custom async tag for Matomo
  • keeping the default Piwik Pro tag active
    Tested it in the debug mode and everything seems right.

Is there anyway you could double verify the set up?

Fact is we are using the Piwik Pro 30-min cookie for users who decline tracking.
And we have outlinks and dowloads to be tracked dynamically.
So I guess it is really a plus to use the Piwik Pro default tag.

Thank you in advance for you help! :slight_smile:

This setup won’t work, since Matomo uses the same paq comand queue as the default Piwik PRO tag. What is suggest then, is implementing Matomo via their plain JavaScript API. In this case, there will be no overlaps. Based on what is installed on your site, the tag that would fire on all pages would look like that:

window.matomoAsyncInit = function () {
        try {
            var matomoTracker = Matomo.getTracker("", 18);
            // additional tracker configuration goes here via matomoTracker.someMethod();
        } catch( err ) {}

  var e = d.createElement(s),
  m = d.getElementsByTagName(s)[0];
  e.async = 1;
  e.src = '';

Here is the list of all methods that can be used to customize the matomo tracker. For Piwik PRO, most of that can be configured directly in the UI. :slight_smile:

Updated the tag with the script you send over and I get this error.
Anything else I can do to correct

? :slight_smile:

I double checked this setup and it turned out it’s prone to race conditions between Matomo and Piwik PRO tracking libraries. Let’s switch to the initial idea that should be safe.

  1. Disable the default Piwik PRO tag.
  2. Create a new custom code tag that would send data to Piwik PRO using an alternative namespace. Trigger: All pages. Consent type: Does not require consent (since the tag handles anonymous tracking as well):
    var _ppas = _ppas || [];
    (function () {
        var trackAnonymously = {{ Piwik PRO Anonymization }}('analytics');
        if (trackAnonymously) {
            _ppas.push(['setUserIsAnonymous', 1]);
    (function() {
        var u = "";
        _ppas.push(["setTrackerUrl", u + "ppms.php"]);
        _ppas.push(["setSiteId", "2c481c7b-7c0e-4a3e-ba23-5233f3af713a"]);
        var d = document,
            g = d.createElement("script"),
            s = d.getElementsByTagName("script")[0];
        g.type = "text/javascript";
        g.async = true;
        g.defer = true;
        g.src = u + "ppas.js";
        s.parentNode.insertBefore(g, s);
  1. Create an additional custom code tag that handles the deanonymization right after the consent is granted. Trigger: All pages. Consent type: Analytics:
var _ppas = window._ppas || [];
    (function () {
        var consents = {{ Consents }};
        var consentType = 'analytics';
        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
        ) {
  1. Revert the Matomo tag to the original code that you used before (the one with _paq.push commands).

Hey Kuba,

Thanks so much for your support!

Maybe a dum question:
If I do not use the default Piwik Pro tag, will I be able to get consent data in the Analytics section?
And to track outlinks and downloads dynamically?

Thank you in advance for your feedback :slight_smile:

It’s not a dum question. Outlinks and downloads would work normally, as those are controlled via this line:


Events connected with consent stats most likely would be sent to Matomo in raw format. So that’s the pain point that would disappear after the full switch.

I think it’s much better than the current solution, as you get 100% of data. Currently, many tracking request might get lost because of race conditions between the JavaScript libraries.

Okay so I updated everything and I have no more console errors! :slight_smile:
Will wait a few days and get back to you to confirm everything is working as it should!

Again thank you so much for your support :slight_smile:

Have a nice day!

I did some checks on your website and it looks all good.

You can now also check Matomo’s Visitor Log and Piwik PRO’s Tracker Debugger to confirm that it looks fine. Just keep in mind that any additional tracking set up via Piwik PRO templates (such as custom events or goals) would be sent to Matomo now. That’s also the reason why consent stats are sent to Matomo. In my opinion, it’s the best we can achieve for now. Looking forward to a full switch in the future. :slight_smile: