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!
Thank you in advance for your feedback,
Best regards,
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
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.
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:
<script>
window.matomoAsyncInit = function () {
try {
var matomoTracker = Matomo.getTracker("https://analytics.esch.lu/matomo.php", 18);
matomoTracker.trackPageView();
// additional tracker configuration goes here via matomoTracker.someMethod();
} catch( err ) {}
};
(function(d,s){
var e = d.createElement(s),
m = d.getElementsByTagName(s)[0];
e.async = 1;
e.src = 'https://analytics.esch.lu/matomo.js';
m.parentNode.insertBefore(e,m);
})(document,'script');
</script>
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.
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.
Disable the default Piwik PRO tag.
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):
<script>
var _ppas = _ppas || [];
(function () {
var trackAnonymously = {{ Piwik PRO Anonymization }}('analytics');
if (trackAnonymously) {
_ppas.push(['setUserIsAnonymous', 1]);
_ppas.push(['disableCookies']);
}
}());
_ppas.push(["trackPageView"]);
_ppas.push(["enableLinkTracking"]);
(function() {
var u = "https://explore-esch.piwik.pro/";
_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);
})();
</script>
Create an additional custom code tag that handles the deanonymization right after the consent is granted. Trigger: All pages. Consent type: Analytics:
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?
It’s not a dum question. Outlinks and downloads would work normally, as those are controlled via this line:
_ppas.push(["enableLinkTracking"]);
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!
Will wait a few days and get back to you to confirm everything is working as it should!
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.